Browse Source

VLCDocumentPickerController:Don't check if the file exists since it's unreliable, in case of error we show the user the error

Carola Nitz 7 years ago
parent
commit
3f2b48828b
1 changed files with 13 additions and 7 deletions
  1. 13 7
      Sources/VLCDocumentPickerController.m

+ 13 - 7
Sources/VLCDocumentPickerController.m

@@ -72,14 +72,20 @@
     NSString *documentsPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) firstObject];
     NSString *filePath = [documentsPath stringByAppendingPathComponent:[url lastPathComponent]];
 
-    if (![fileManager fileExistsAtPath:filePath]) {
-        NSError *error = nil;
-        BOOL success = [fileManager moveItemAtPath:[url path] toPath:filePath error:&error];
-
-        if (success) {
-            [[VLCMediaFileDiscoverer sharedInstance] updateMediaList];
-        }
+    NSError *error = nil;
+    BOOL success = [fileManager moveItemAtPath:[url path] toPath:filePath error:&error];
+    if (!error) {
+        [[VLCMediaFileDiscoverer sharedInstance] updateMediaList];
+    } else {
+        UIAlertController *alert = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"GDRIVE_ERROR_DOWNLOADING_FILE_TITLE", nil) message:error.description preferredStyle:UIAlertControllerStyleAlert];
+        UIViewController *rootVC = [UIApplication sharedApplication].keyWindow.rootViewController;
+        UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
+            [rootVC dismissViewControllerAnimated:true completion:nil];
+        }];
+        [alert addAction:okAction];
+        [rootVC presentViewController:alert animated:true completion:nil];
     }
+
 }
 
 @end