Jelajahi Sumber

plex: check for available space left on device prior to downloading

Signed-off-by: Felix Paul Kühne <fkuehne@videolan.org>
Pierre SAGASPE 10 tahun lalu
induk
melakukan
dd8613063b
1 mengubah file dengan 11 tambahan dan 4 penghapusan
  1. 11 4
      Sources/VLCLocalPlexFolderListViewController.m

+ 11 - 4
Sources/VLCLocalPlexFolderListViewController.m

@@ -21,6 +21,7 @@
 #import "VLCStatusLabel.h"
 #import "VLCAlertView.h"
 #import "UIBarButtonItem+Theme.h"
+#import "UIDevice+VLC.h"
 
 @interface VLCLocalPlexFolderListViewController () <UITableViewDataSource, UITableViewDelegate, VLCLocalNetworkListCell, UISearchBarDelegate, UISearchDisplayDelegate>
 {
@@ -397,11 +398,17 @@
     [ObjList removeAllObjects];
     ObjList = [_PlexParser PlexMediaServerParser:_PlexServerAddress port:_PlexServerPort navigationPath:path];
 
-    if ([[ObjList objectAtIndex:0] objectForKey:@"keySubtitle"])
-        [self _getFileSubtitleFromPlexServer:ObjList modeStream:NO];
+    NSInteger size = [[[ObjList objectAtIndex:0] objectForKey:@"size"] integerValue];
+    if (size  < [[UIDevice currentDevice] freeDiskspace].longLongValue) {
+        if ([[ObjList objectAtIndex:0] objectForKey:@"keySubtitle"])
+            [self _getFileSubtitleFromPlexServer:ObjList modeStream:NO];
 
-    [self _downloadFileFromMediaItem:ObjList];
-    [cell.statusLabel showStatusMessage:NSLocalizedString(@"DOWNLOADING", nil)];
+        [self _downloadFileFromMediaItem:ObjList];
+        [cell.statusLabel showStatusMessage:NSLocalizedString(@"DOWNLOADING", nil)];
+    } else {
+        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"DISK_FULL", nil) message:[NSString stringWithFormat:NSLocalizedString(@"DISK_FULL_FORMAT", nil), [[ObjList objectAtIndex:0] objectForKey:@"title"], [[UIDevice currentDevice] model]] delegate:self cancelButtonTitle:NSLocalizedString(@"BUTTON_OK", nil) otherButtonTitles:nil];
+        [alert show];
+    }
 }
 
 #pragma mark - Search Display Controller Delegate