summaryrefslogtreecommitdiffstats
path: root/macosx/HBQueueController.m
diff options
context:
space:
mode:
authorDamiano Galassi <[email protected]>2017-06-15 09:07:39 +0200
committerDamiano Galassi <[email protected]>2017-06-15 09:07:39 +0200
commit7aaee9a9b0af21ac56549e4fd32c877e53f7f48b (patch)
tree8f796a19c669d8ea69667ceaf26d49d8a194e1fe /macosx/HBQueueController.m
parent0dc659ba728b5570564ef09cf1d73c8110529def (diff)
MacGui: add a preferences option to configure the queue low disk space warning.
Diffstat (limited to 'macosx/HBQueueController.m')
-rw-r--r--macosx/HBQueueController.m35
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;
+ }
}
}
}