Skip to content

Commit e2e69e3

Browse files
Remove temporary files on app termination
1 parent 905d660 commit e2e69e3

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

AppBox/AppDelegate.m

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ - (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
7070
- (void)applicationWillTerminate:(NSNotification *)aNotification {
7171
DDLogInfo(@"AppBox Terminated.");
7272
[self saveCoreDataChanges];
73+
[self deleteTemporaryFiles];
7374
}
7475

7576
- (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)sender{
@@ -325,4 +326,12 @@ - (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sende
325326
return NSTerminateNow;
326327
}
327328

329+
// MARK: - Other helpers
330+
- (void)deleteTemporaryFiles {
331+
NSArray* tmpDirectory = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:NSTemporaryDirectory() error:NULL];
332+
for (NSString *file in tmpDirectory) {
333+
[[NSFileManager defaultManager] removeItemAtPath:[NSString stringWithFormat:@"%@%@", NSTemporaryDirectory(), file] error:NULL];
334+
}
335+
}
336+
328337
@end

0 commit comments

Comments
 (0)