From 271f70a3e4a198a26ab300be1309675b661fbd96 Mon Sep 17 00:00:00 2001 From: Damiano Galassi Date: Fri, 11 Nov 2016 18:20:25 +0100 Subject: [PATCH] OCD. --- Base.lproj/Queue.xib | 6 +++--- Classes/SBQueueItem.m | 24 +++++++++++++----------- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/Base.lproj/Queue.xib b/Base.lproj/Queue.xib index 9e9856c..0c2e1c9 100755 --- a/Base.lproj/Queue.xib +++ b/Base.lproj/Queue.xib @@ -1,8 +1,8 @@ - + - + @@ -29,7 +29,7 @@ - + diff --git a/Classes/SBQueueItem.m b/Classes/SBQueueItem.m index 57a942a..6377c0b 100755 --- a/Classes/SBQueueItem.m +++ b/Classes/SBQueueItem.m @@ -294,6 +294,8 @@ noErr = [self prepare:outError]; } + NSURL *filePathURL = self.fileURL.filePathURL; + if (!noErr) { goto bail; } { @@ -303,10 +305,10 @@ }; // Check if there is enough space on the destination disk - if (![self.fileURL isEqualTo:self.destURL]) { - NSDictionary *dict = [[NSFileManager defaultManager] attributesOfFileSystemForPath:(self.destURL).URLByDeletingLastPathComponent.path error:NULL]; + if (![filePathURL isEqualTo:self.destURL]) { + NSDictionary *dict = [[NSFileManager defaultManager] attributesOfFileSystemForPath:self.destURL.URLByDeletingLastPathComponent.path error:NULL]; NSNumber *freeSpace = dict[NSFileSystemFreeSize]; - if (freeSpace && (self.mp4File).dataSize > freeSpace.longLongValue) { + if (freeSpace && self.mp4File.dataSize > freeSpace.longLongValue) { noErr = NO; if (outError) { NSDictionary *errorDetail = @{ NSLocalizedDescriptionKey : @"Not enough disk space", @@ -317,15 +319,8 @@ } } - // 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 - [self willChangeValueForKey:@"fileURL"]; - _fileURL = self.fileURL.filePathURL; - [self didChangeValueForKey:@"fileURL"]; - if (!self.cancelled) { - if ([self.fileURL isEqualTo:self.destURL] && self.mp4File.hasFileRepresentation) { + if ([filePathURL isEqualTo:self.destURL] && self.mp4File.hasFileRepresentation) { // We have an existing mp4 file, update it noErr = [self.mp4File updateMP4FileWithOptions:self.attributes error:outError]; } @@ -362,6 +357,13 @@ bail: self.mp4File.progressHandler = nil; self.mp4File = nil; + // 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 + [self willChangeValueForKey:@"fileURL"]; + _fileURL = filePathURL; + [self didChangeValueForKey:@"fileURL"]; + #ifdef SB_SANDBOX if ([destination respondsToSelector:@selector(stopAccessingSecurityScopedResource)]) [destination stopAccessingSecurityScopedResource];