From: Damiano Galassi Date: Thu, 15 Jun 2017 07:07:39 +0000 (+0200) Subject: MacGui: add a preferences option to configure the queue low disk space warning. X-Git-Tag: 1.1.0~517 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7aaee9a9b0af21ac56549e4fd32c877e53f7f48b;p=handbrake MacGui: add a preferences option to configure the queue low disk space warning. --- diff --git a/macosx/English.lproj/Preferences.xib b/macosx/English.lproj/Preferences.xib index fcc95b3f5..87c7ca924 100644 --- a/macosx/English.lproj/Preferences.xib +++ b/macosx/English.lproj/Preferences.xib @@ -1,9 +1,10 @@ - + - - + + + @@ -27,7 +28,7 @@ - + @@ -219,7 +220,7 @@ - + @@ -446,14 +447,14 @@ - + - + - + @@ -471,7 +472,7 @@ - + @@ -494,7 +495,7 @@ - + @@ -522,7 +523,7 @@ - + @@ -530,7 +531,7 @@ - + @@ -538,7 +539,7 @@ - + @@ -546,7 +547,7 @@ - + @@ -554,7 +555,7 @@ - + @@ -562,7 +563,7 @@ - + @@ -570,7 +571,7 @@ - + @@ -578,7 +579,7 @@ - + @@ -586,7 +587,7 @@ - + @@ -601,7 +602,7 @@ - + @@ -646,8 +647,8 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -705,22 +752,27 @@ This setting is no longer supported and may be removed in a future version. Use - + + + + + + @@ -732,7 +784,7 @@ This setting is no longer supported and may be removed in a future version. Use - + diff --git a/macosx/HBPreferencesController.m b/macosx/HBPreferencesController.m index 90f23d9b4..b24219b34 100644 --- a/macosx/HBPreferencesController.m +++ b/macosx/HBPreferencesController.m @@ -77,7 +77,9 @@ @"x264CqSliderFractional": @"0.50", @"HBShowAdvancedTab": @NO, @"HBAutoNamingFormat": @[@"{Source}", @" ", @"{Title}"], - @"HBDrawerSize": NSStringFromSize(NSMakeSize(184, 591)) + @"HBDrawerSize": NSStringFromSize(NSMakeSize(184, 591)), + @"HBQueuePauseIfLowSpace": @YES, + @"HBQueueMinFreeSpace": @"2" }]; // Overwrite the update check interval because previous versions 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 *attrs = [url resourceValuesForKeys:@[NSURLIsVolumeKey, NSURLVolumeURLKey] error:NULL]; + if ([[NSUserDefaults standardUserDefaults] boolForKey:@"HBQueuePauseIfLowSpace"]) + { + NSURL *volumeURL = nil; + NSDictionary *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; + } } } }