diff options
Diffstat (limited to 'macosx/HBQueueController.m')
-rw-r--r-- | macosx/HBQueueController.m | 35 |
1 files changed, 18 insertions, 17 deletions
diff --git a/macosx/HBQueueController.m b/macosx/HBQueueController.m index e26b2dc14..8ce96e9ec 100644 --- a/macosx/HBQueueController.m +++ b/macosx/HBQueueController.m @@ -537,31 +537,32 @@ self.completedItemsCount = completedCount; } -#pragma mark - -#pragma mark Queue Job Processing - -#define ALMOST_2GB 2000000000 +#pragma mark - Queue Job Processing - (BOOL)_isDiskSpaceLowAtURL:(NSURL *)url { - NSURL *volumeURL = nil; - NSDictionary<NSURLResourceKey, id> *attrs = [url resourceValuesForKeys:@[NSURLIsVolumeKey, NSURLVolumeURLKey] error:NULL]; + if ([[NSUserDefaults standardUserDefaults] boolForKey:@"HBQueuePauseIfLowSpace"]) + { + NSURL *volumeURL = nil; + NSDictionary<NSURLResourceKey, id> *attrs = [url resourceValuesForKeys:@[NSURLIsVolumeKey, NSURLVolumeURLKey] error:NULL]; + long long minCapacity = [[[NSUserDefaults standardUserDefaults] stringForKey:@"HBQueueMinFreeSpace"] longLongValue] * 1000000000; - volumeURL = [attrs[NSURLIsVolumeKey] boolValue] ? url : attrs[NSURLVolumeURLKey]; + volumeURL = [attrs[NSURLIsVolumeKey] boolValue] ? url : attrs[NSURLVolumeURLKey]; - if (volumeURL) - { - if ([volumeURL respondsToSelector:@selector(removeCachedResourceValueForKey:)]) + if (volumeURL) { - [volumeURL removeCachedResourceValueForKey:NSURLVolumeAvailableCapacityKey]; - } - attrs = [volumeURL resourceValuesForKeys:@[NSURLVolumeAvailableCapacityKey] error:NULL]; + if ([volumeURL respondsToSelector:@selector(removeCachedResourceValueForKey:)]) + { + [volumeURL removeCachedResourceValueForKey:NSURLVolumeAvailableCapacityKey]; + } + attrs = [volumeURL resourceValuesForKeys:@[NSURLVolumeAvailableCapacityKey] error:NULL]; - if (attrs[NSURLVolumeAvailableCapacityKey]) - { - if ([attrs[NSURLVolumeAvailableCapacityKey] longLongValue] < ALMOST_2GB) + if (attrs[NSURLVolumeAvailableCapacityKey]) { - return YES; + if ([attrs[NSURLVolumeAvailableCapacityKey] longLongValue] < minCapacity) + { + return YES; + } } } } |