From 1af79e413bd7e8d6e75604690942d6dddeb4ec97 Mon Sep 17 00:00:00 2001 From: sr55 Date: Mon, 29 May 2017 19:35:36 +0100 Subject: [PATCH] WinGui: Improved error message on Starting an encode or queue when the destination drive is low on space. Fixes #748 --- win/CS/HandBrakeWPF/Properties/Resources.Designer.cs | 9 +++++++++ win/CS/HandBrakeWPF/Properties/Resources.resx | 3 +++ win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs | 8 ++++++++ win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs | 11 ++++++++++- 4 files changed, 30 insertions(+), 1 deletion(-) diff --git a/win/CS/HandBrakeWPF/Properties/Resources.Designer.cs b/win/CS/HandBrakeWPF/Properties/Resources.Designer.cs index 92d55b507..aa6a7e1a0 100644 --- a/win/CS/HandBrakeWPF/Properties/Resources.Designer.cs +++ b/win/CS/HandBrakeWPF/Properties/Resources.Designer.cs @@ -722,6 +722,15 @@ namespace HandBrakeWPF.Properties { } } + /// + /// Looks up a localized string similar to Your destination directory is low on diskspace. Please free up some disk space on your destination drive. Alternatively you can change the level at which this alert triggers in Options. . + /// + public static string Main_LowDiskspace { + get { + return ResourceManager.GetString("Main_LowDiskspace", resourceCulture); + } + } + /// /// Looks up a localized string similar to You cannot encode to a file with the same path and filename as the source file. Please update the destination filename so that it does not match the source file.. /// diff --git a/win/CS/HandBrakeWPF/Properties/Resources.resx b/win/CS/HandBrakeWPF/Properties/Resources.resx index 6a67940ad..c765c9423 100644 --- a/win/CS/HandBrakeWPF/Properties/Resources.resx +++ b/win/CS/HandBrakeWPF/Properties/Resources.resx @@ -849,4 +849,7 @@ Remaining Time: {4} Queue Paused + + Your destination directory is low on diskspace. Please free up some disk space on your destination drive. Alternatively you can change the level at which this alert triggers in Options. + \ No newline at end of file diff --git a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs index 5056f99a6..93aac9c19 100644 --- a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs @@ -1661,6 +1661,14 @@ namespace HandBrakeWPF.ViewModels return; } + if (!DriveUtilities.HasMinimumDiskSpace( + this.Destination, + this.userSettingService.GetUserSetting(UserSettingConstants.PauseOnLowDiskspaceLevel))) + { + this.errorService.ShowMessageBox(Resources.Main_LowDiskspace, Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error); + return; + } + if (this.scannedSource != null && !string.IsNullOrEmpty(this.scannedSource.ScanPath) && this.Destination.ToLower() == this.scannedSource.ScanPath.ToLower()) { this.errorService.ShowMessageBox(Resources.Main_MatchingFileOverwriteWarning, Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error); diff --git a/win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs index 4cd2948db..5e9f45aa7 100644 --- a/win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs @@ -23,6 +23,7 @@ namespace HandBrakeWPF.ViewModels using HandBrakeWPF.Services.Interfaces; using HandBrakeWPF.Services.Queue.Interfaces; using HandBrakeWPF.Services.Queue.Model; + using HandBrakeWPF.Utilities; using HandBrakeWPF.ViewModels.Interfaces; using Microsoft.Win32; @@ -371,13 +372,21 @@ namespace HandBrakeWPF.ViewModels /// public void StartQueue() { - if (this.queueProcessor.Count == 0) + if (this.queueProcessor.Count == 0 || !this.QueueTasks.Any(a => a.Status == QueueItemStatus.Waiting || a.Status == QueueItemStatus.InProgress)) { this.errorService.ShowMessageBox( Resources.QueueViewModel_NoPendingJobs, Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error); return; } + var firstOrDefault = this.QueueTasks.FirstOrDefault(s => s.Status == QueueItemStatus.Waiting); + if (firstOrDefault != null && !DriveUtilities.HasMinimumDiskSpace(firstOrDefault.Task.Destination, + this.userSettingService.GetUserSetting(UserSettingConstants.PauseOnLowDiskspaceLevel))) + { + this.errorService.ShowMessageBox(Resources.Main_LowDiskspace, Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error); + return; + } + this.JobStatus = Resources.QueueViewModel_QueueStarted; this.JobsPending = string.Format(Resources.QueueViewModel_JobsPending, this.queueProcessor.Count); this.IsQueueRunning = true; -- 2.40.0