Commit d4624a82 authored by Pierre SAGASPE's avatar Pierre SAGASPE Committed by Felix Paul Kühne
Browse files

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


Signed-off-by: Felix Paul Kühne's avatarFelix Paul Kühne <fkuehne@videolan.org>
parent e2f46ea1
......@@ -26,6 +26,7 @@
#import "VLCStatusLabel.h"
#import "BasicUPnPDevice+VLC.h"
#import "UIBarButtonItem+Theme.h"
#import "UIDevice+VLC.h"
#define kVLCServerTypeUPNP 0
#define kVLCServerTypeFTP 1
......@@ -667,15 +668,18 @@
[cell.statusLabel showStatusMessage:NSLocalizedString(@"DOWNLOADING", nil)];
}else if (_serverType == kVLCServerTypeFTP) {
NSString *rawObjectName;
NSInteger size;
NSMutableArray *ObjList = [[NSMutableArray alloc] init];
[ObjList removeAllObjects];
if ([self.searchDisplayController isActive]) {
[ObjList addObjectsFromArray:_searchData];
rawObjectName = [ObjList[[self.searchDisplayController.searchResultsTableView indexPathForCell:cell].row] objectForKey:(id)kCFFTPResourceName];
size = [[ObjList[[self.searchDisplayController.searchResultsTableView indexPathForCell:cell].row] objectForKey:(id)kCFFTPResourceSize] intValue];
} else {
[ObjList addObjectsFromArray:_objectList];
rawObjectName = [ObjList[[self.tableView indexPathForCell:cell].row] objectForKey:(id)kCFFTPResourceName];
size = [[ObjList[[self.tableView indexPathForCell:cell].row] objectForKey:(id)kCFFTPResourceSize] intValue];
}
NSData *flippedData = [rawObjectName dataUsingEncoding:[[[NSUserDefaults standardUserDefaults] objectForKey:kVLCSettingFTPTextEncoding] intValue] allowLossyConversion:YES];
......@@ -684,8 +688,13 @@
UIAlertView * alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"FILE_NOT_SUPPORTED", nil) message:[NSString stringWithFormat:NSLocalizedString(@"FILE_NOT_SUPPORTED_LONG", nil), properObjectName] delegate:self cancelButtonTitle:NSLocalizedString(@"BUTTON_CANCEL", nil) otherButtonTitles:nil];
[alert show];
} else {
[self _downloadFTPFile:properObjectName];
[cell.statusLabel showStatusMessage:NSLocalizedString(@"DOWNLOADING", nil)];
if (size < [[UIDevice currentDevice] freeDiskspace].longLongValue) {
[self _downloadFTPFile:properObjectName];
[cell.statusLabel showStatusMessage:NSLocalizedString(@"DOWNLOADING", nil)];
} else {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"DISK_FULL", nil) message:[NSString stringWithFormat:NSLocalizedString(@"DISK_FULL_FORMAT", nil), properObjectName, [[UIDevice currentDevice] model]] delegate:self cancelButtonTitle:NSLocalizedString(@"BUTTON_OK", nil) otherButtonTitles:nil];
[alert show];
}
}
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment