Commit d7e19aa0 authored by Pierre SAGASPE's avatar Pierre SAGASPE Committed by Felix Paul Kühne

httpDownloader: 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 d4624a82
......@@ -14,6 +14,7 @@
#import "VLCHTTPFileDownloader.h"
#import "NSString+SupportedMedia.h"
#import "VLCAppDelegate.h"
#import "UIDevice+VLC.h"
@interface VLCHTTPFileDownloader ()
{
......@@ -122,7 +123,14 @@
[self _downloadEnded];
} else {
_expectedDownloadSize = [response expectedContentLength];
[self.delegate downloadStarted];
if (_expectedDownloadSize < [[UIDevice currentDevice] freeDiskspace].longLongValue)
[self.delegate downloadStarted];
else {
[_urlConnection cancel];
[self _downloadEnded];
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"DISK_FULL", nil) message:[NSString stringWithFormat:NSLocalizedString(@"DISK_FULL_FORMAT", nil), _fileName, [[UIDevice currentDevice] model]] delegate:self cancelButtonTitle:NSLocalizedString(@"BUTTON_OK", nil) otherButtonTitles:nil];
[alert show];
}
APLog(@"expected download size: %lu", (unsigned long)_expectedDownloadSize);
}
} else {
......
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