Forráskód Böngészése

http upload: clean cache prior to starting a new instance to addition to cache cleaning on app launch

Felix Paul Kühne 11 éve
szülő
commit
d8eed78b80

+ 2 - 0
Sources/VLCAppDelegate.h

@@ -29,6 +29,8 @@
 - (void)disableIdleTimer;
 - (void)activateIdleTimer;
 
+- (void)cleanCache;
+
 - (void)openMediaFromManagedObject:(NSManagedObject *)file;
 - (void)openMovieFromURL:(NSURL *)url;
 - (void)openMediaList:(VLCMediaList*)list atIndex:(int)index;

+ 10 - 5
Sources/VLCAppDelegate.m

@@ -66,11 +66,7 @@
     [quincyManager startManager];
 
     /* clean caches on launch (since those are used for wifi upload only) */
-    NSArray *searchPaths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
-    NSString* uploadDirPath = [searchPaths[0] stringByAppendingPathComponent:@"Upload"];
-    NSFileManager *fileManager = [NSFileManager defaultManager];
-    if ([fileManager fileExistsAtPath:uploadDirPath])
-        [fileManager removeItemAtPath:uploadDirPath error:nil];
+    [self cleanCache];
 
     // Init the HTTP Server
     self.uploadController = [[VLCHTTPUploaderController alloc] init];
@@ -228,6 +224,15 @@
     [_playlistViewController updateViewContents];
 }
 
+- (void)cleanCache
+{
+    NSArray *searchPaths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
+    NSString* uploadDirPath = [searchPaths[0] stringByAppendingPathComponent:@"Upload"];
+    NSFileManager *fileManager = [NSFileManager defaultManager];
+    if ([fileManager fileExistsAtPath:uploadDirPath])
+        [fileManager removeItemAtPath:uploadDirPath error:nil];
+}
+
 #pragma mark - media list methods
 
 - (NSString *)directoryPath

+ 3 - 0
Sources/VLCHTTPUploaderController.m

@@ -70,6 +70,9 @@
         [self.httpServer stop];
         return true;
     }
+    // clean cache before accepting new stuff
+    [(VLCAppDelegate *)[UIApplication sharedApplication].delegate cleanCache];
+
     // Initialize our http server
     _httpServer = [[HTTPServer alloc] init];
     [_httpServer setInterface:WifiInterfaceName];