From 7396e7aa6921da16df48728184b52e8a5bd60198 Mon Sep 17 00:00:00 2001 From: Eric Warmenhoven Date: Thu, 28 Dec 2023 14:10:13 -0500 Subject: [PATCH] Cloud sync fixes - ignore .DS_Store files and re-sync on app foreground (#16055) --- tasks/task_cloudsync.c | 3 +++ ui/drivers/cocoa/apple_platform.h | 1 + ui/drivers/ui_cocoatouch.m | 14 ++++++++++++++ 3 files changed, 18 insertions(+) diff --git a/tasks/task_cloudsync.c b/tasks/task_cloudsync.c index a44baee22ddc..532ef63d2c63 100644 --- a/tasks/task_cloudsync.c +++ b/tasks/task_cloudsync.c @@ -255,6 +255,9 @@ static bool task_cloud_sync_should_ignore_file(const char *filename) return true; } + if (string_ends_with(filename, "/.DS_Store")) + return true; + return false; } diff --git a/ui/drivers/cocoa/apple_platform.h b/ui/drivers/cocoa/apple_platform.h index 237badb6ccfa..e83878097401 100644 --- a/ui/drivers/cocoa/apple_platform.h +++ b/ui/drivers/cocoa/apple_platform.h @@ -72,6 +72,7 @@ UINavigationControllerDelegate> { @property (nonatomic) UIWindow* window; @property (nonatomic) NSString* documentsDirectory; @property (nonatomic) int menu_count; +@property (nonatomic) NSDate *bgDate; + (RetroArch_iOS*)get; diff --git a/ui/drivers/ui_cocoatouch.m b/ui/drivers/ui_cocoatouch.m index fcd4c0a5ae8a..90c1c7c6c86d 100644 --- a/ui/drivers/ui_cocoatouch.m +++ b/ui/drivers/ui_cocoatouch.m @@ -559,6 +559,11 @@ - (void)applicationWillTerminate:(UIApplication *)application retroarch_main_quit(); } +- (void)applicationWillResignActive:(UIApplication *)application +{ + self.bgDate = [NSDate date]; +} + - (void)applicationDidBecomeActive:(UIApplication *)application { rarch_start_draw_observer(); @@ -573,6 +578,15 @@ - (void)applicationDidBecomeActive:(UIApplication *)application if (!ui_companion_start_on_boot) [self showGameView]; + + if (self.bgDate) + { + if ( [[NSDate date] timeIntervalSinceDate:self.bgDate] > 60.0f + && ( !(runloop_get_flags() & RUNLOOP_FLAG_CORE_RUNNING) + || retroarch_ctl(RARCH_CTL_IS_DUMMY_CORE, NULL))) + task_push_cloud_sync(); + self.bgDate = nil; + } } -(BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary *)options {