From 9bf5d04050c3ef13179c99119dd89c83e8cb3bd8 Mon Sep 17 00:00:00 2001 From: Damiano Galassi Date: Tue, 9 Dec 2014 16:10:09 +0100 Subject: [PATCH] Run the check for disk space only if saving to a new file. --- Classes/SBQueueItem.m | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/Classes/SBQueueItem.m b/Classes/SBQueueItem.m index f8cb212..0a0f0fc 100755 --- a/Classes/SBQueueItem.m +++ b/Classes/SBQueueItem.m @@ -264,19 +264,21 @@ self.mp4File.delegate = self; - // Check if there is enough space on the dest disk - NSDictionary *dict = [[NSFileManager defaultManager] attributesOfFileSystemForPath:[[self.destURL URLByDeletingLastPathComponent] path] error:NULL]; - NSNumber *freeSpace = [dict objectForKey:NSFileSystemFreeSize]; - if (freeSpace && [self.mp4File dataSize] > [freeSpace longLongValue]) { - noErr = NO; - if (outError) { - NSDictionary *errorDetail = @{ NSLocalizedDescriptionKey : @"Not enough disk space", - NSLocalizedRecoverySuggestionErrorKey : @"" }; - *outError = [NSError errorWithDomain:@"SBQueueItemError" code:12 userInfo:errorDetail]; + // Check if there is enough space on the destination disk + if (![self.URL isEqualTo:self.destURL]) { + NSDictionary *dict = [[NSFileManager defaultManager] attributesOfFileSystemForPath:[[self.destURL URLByDeletingLastPathComponent] path] error:NULL]; + NSNumber *freeSpace = [dict objectForKey:NSFileSystemFreeSize]; + if (freeSpace && [self.mp4File dataSize] > [freeSpace longLongValue]) { + noErr = NO; + if (outError) { + NSDictionary *errorDetail = @{ NSLocalizedDescriptionKey : @"Not enough disk space", + NSLocalizedRecoverySuggestionErrorKey : @"" }; + *outError = [NSError errorWithDomain:@"SBQueueItemError" code:12 userInfo:errorDetail]; + } + goto bail; } - goto bail; } - + // Convert from a file reference url to a normal url // the file will be replaced if optimized, and the reference url // may point to nil