diff options
author | Damiano Galassi <[email protected]> | 2016-09-07 12:50:54 +0200 |
---|---|---|
committer | Damiano Galassi <[email protected]> | 2016-09-07 12:50:54 +0200 |
commit | e9b2d291789edf2d08453c6554e1594aedfd495d (patch) | |
tree | dda704f4bb5fb640afd365fdcf6c0c9318f9e77f | |
parent | 496680b6c71c2844f8040e1073b5fa8e16914429 (diff) |
MacGui: stop the queue and show an alert if disk space is less than 5 GB
-rw-r--r-- | macosx/HBQueueController.m | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/macosx/HBQueueController.m b/macosx/HBQueueController.m index 6d408d03d..0fa541a2d 100644 --- a/macosx/HBQueueController.m +++ b/macosx/HBQueueController.m @@ -535,6 +535,18 @@ #pragma mark - #pragma mark Queue Job Processing +#define ALMOST_5GB 5000000000 + +- (BOOL)_isDiskSpaceLowAtURL:(NSURL *)url +{ + NSDictionary *dict = [[NSFileManager defaultManager] attributesOfFileSystemForPath:url.URLByDeletingLastPathComponent.path error:NULL]; + long long freeSpace = [dict[NSFileSystemFreeSize] longLongValue]; + if (freeSpace < ALMOST_5GB) { + return YES; + } + return NO; +} + /** * Used to get the next pending queue item and return it if found */ @@ -568,8 +580,15 @@ // Check to see if there are any more pending items in the queue HBJob *nextJob = [self getNextPendingQueueItem]; + if (nextJob && [self _isDiskSpaceLowAtURL:nextJob.destURL]) + { + // Disk space is low, show an alert + [HBUtilities writeToActivityLog:"Queue Stopped, low space on destination disk"]; + + [self queueLowDiskSpaceAlert]; + } // If we still have more pending items in our queue, lets go to the next one - if (nextJob) + else if (nextJob) { // now we mark the queue item as working so another instance can not come along and try to scan it while we are scanning nextJob.state = HBJobStateWorking; @@ -937,6 +956,15 @@ } } +- (void)queueLowDiskSpaceAlert +{ + NSAlert *alert = [[NSAlert alloc] init]; + [alert setMessageText:NSLocalizedString(@"Your destination disk is almost full.", @"")]; + [alert setInformativeText:NSLocalizedString(@"You need to make more space available on your destination disk.", @"")]; + [NSApp requestUserAttention:NSCriticalRequest]; + [alert runModal]; +} + #pragma mark - Queue Item Controls - (void)HB_deleteSelectionFromTableView:(NSTableView *)tableView |