diff options
author | Tor Lillqvist <tml@collabora.com> | 2021-09-07 13:08:25 +0300 |
---|---|---|
committer | Tor Lillqvist <tml@iki.fi> | 2021-09-07 15:29:12 +0300 |
commit | 780741c0f9aab4f91b974de3b2762d22251af98c (patch) | |
tree | 2b06e123b54c8d7123e6fe47a52f617a613e87ab | |
parent | Stop using .bmp files for tiles on iOS (diff) | |
download | online-780741c0f9aab4f91b974de3b2762d22251af98c.tar.gz online-780741c0f9aab4f91b974de3b2762d22251af98c.zip |
Remove leftover temp files harder in the iOS app when it starts
Just clean out the whole tmp folder.
This gets rid of copies of edited documents left behind if the app is
killed (or crashes) while editing a document. It also gets rid of
files that NSS loves to leave around. Plus empty folders that are left
even when the app dies normally, i.e. while it isn't editing any
document.
Signed-off-by: Tor Lillqvist <tml@collabora.com>
Change-Id: If1caf8ace666eafc58df981d792f8fbfda8f9ff4
-rw-r--r-- | ios/Mobile/AppDelegate.mm | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/ios/Mobile/AppDelegate.mm b/ios/Mobile/AppDelegate.mm index 8e200afd0f..391f334695 100644 --- a/ios/Mobile/AppDelegate.mm +++ b/ios/Mobile/AppDelegate.mm @@ -290,6 +290,18 @@ static void updateTemplates(NSData *data, NSURLResponse *response) if (user_name == nullptr) user_name = [[[NSUserDefaults standardUserDefaults] stringForKey:@"userName"] UTF8String]; + // Remove any leftover allegedly temporary folders with copies of documents left behind from + // previous instances of the app that were killed while editing, various random files that for + // instance NSS seems to love to create, etc, by removing the whole tmp folder. + NSURL *tempFolderURL = [[NSFileManager defaultManager] temporaryDirectory]; + if (![[NSFileManager defaultManager] removeItemAtURL:tempFolderURL error:nil]) { + NSLog(@"Could not remove tmp folder %@", tempFolderURL); + } + + if (![[NSFileManager defaultManager] createDirectoryAtURL:tempFolderURL withIntermediateDirectories:YES attributes:nil error:nil]) { + NSLog(@"Could not create tile bitmap folder %@", tempFolderURL); + } + fakeSocketSetLoggingCallback([](const std::string& line) { LOG_INF_NOFILE(line); |