Run the check for disk space only if saving to a new file.

This commit is contained in:
Damiano Galassi committed 2014-12-09 16:10:09 +01:00
1 parent 185325d68b
commit 9bf5d04050
1 file changed
+13 -11
+13 -11
View File
@@ -264,19 +264,21 @@
self.mp4File.delegate = self; self.mp4File.delegate = self;
// Check if there is enough space on the dest disk // Check if there is enough space on the destination disk
NSDictionary *dict = [[NSFileManager defaultManager] attributesOfFileSystemForPath:[[self.destURL URLByDeletingLastPathComponent] path] error:NULL]; if (![self.URL isEqualTo:self.destURL]) {
NSNumber *freeSpace = [dict objectForKey:NSFileSystemFreeSize]; NSDictionary *dict = [[NSFileManager defaultManager] attributesOfFileSystemForPath:[[self.destURL URLByDeletingLastPathComponent] path] error:NULL];
if (freeSpace && [self.mp4File dataSize] > [freeSpace longLongValue]) { NSNumber *freeSpace = [dict objectForKey:NSFileSystemFreeSize];
noErr = NO; if (freeSpace && [self.mp4File dataSize] > [freeSpace longLongValue]) {
if (outError) { noErr = NO;
NSDictionary *errorDetail = @{ NSLocalizedDescriptionKey : @"Not enough disk space", if (outError) {
NSLocalizedRecoverySuggestionErrorKey : @"" }; NSDictionary *errorDetail = @{ NSLocalizedDescriptionKey : @"Not enough disk space",
*outError = [NSError errorWithDomain:@"SBQueueItemError" code:12 userInfo:errorDetail]; NSLocalizedRecoverySuggestionErrorKey : @"" };
*outError = [NSError errorWithDomain:@"SBQueueItemError" code:12 userInfo:errorDetail];
}
goto bail;
} }
goto bail;
} }
// Convert from a file reference url to a normal url // Convert from a file reference url to a normal url
// the file will be replaced if optimized, and the reference url // the file will be replaced if optimized, and the reference url
// may point to nil // may point to nil