summaryrefslogtreecommitdiffstats
path: root/win/CS/HandBrakeWPF/Services/Queue
diff options
context:
space:
mode:
authorScott <[email protected]>2015-11-10 23:21:57 +0000
committerScott <[email protected]>2015-11-10 23:21:57 +0000
commit6b713adaa58a127a65a5e69a6507d894a4760884 (patch)
tree56a37c568826e3ab1503e6523b6ad1ebc5bacce9 /win/CS/HandBrakeWPF/Services/Queue
parent6fd35381a879def5e76f99cded43a2a3c265c333 (diff)
WinGui: Add warning dialog on Destination Browse Button if disk space is low. Added new Advanced Option in preferences that will force the queue to check for low disk space before starting each job and pause if necessary.
Low Disk Space level is currently set at 10GB. Will add a preference to adjust this at a later point
Diffstat (limited to 'win/CS/HandBrakeWPF/Services/Queue')
-rw-r--r--win/CS/HandBrakeWPF/Services/Queue/Interfaces/IQueueProcessor.cs7
-rw-r--r--win/CS/HandBrakeWPF/Services/Queue/QueueProcessor.cs41
2 files changed, 47 insertions, 1 deletions
diff --git a/win/CS/HandBrakeWPF/Services/Queue/Interfaces/IQueueProcessor.cs b/win/CS/HandBrakeWPF/Services/Queue/Interfaces/IQueueProcessor.cs
index d0bef608f..e148269ff 100644
--- a/win/CS/HandBrakeWPF/Services/Queue/Interfaces/IQueueProcessor.cs
+++ b/win/CS/HandBrakeWPF/Services/Queue/Interfaces/IQueueProcessor.cs
@@ -44,6 +44,13 @@ namespace HandBrakeWPF.Services.Queue.Interfaces
/// </summary>
event EventHandler QueuePaused;
+
+ /// <summary>
+ /// Low Diskspace has been detected.
+ /// Checked before each job starts.
+ /// </summary>
+ event EventHandler LowDiskspaceDetected;
+
#endregion
#region Properties
diff --git a/win/CS/HandBrakeWPF/Services/Queue/QueueProcessor.cs b/win/CS/HandBrakeWPF/Services/Queue/QueueProcessor.cs
index 31fd7acee..59b321d7b 100644
--- a/win/CS/HandBrakeWPF/Services/Queue/QueueProcessor.cs
+++ b/win/CS/HandBrakeWPF/Services/Queue/QueueProcessor.cs
@@ -14,8 +14,12 @@ namespace HandBrakeWPF.Services.Queue
using System.ComponentModel;
using System.IO;
using System.Linq;
+ using System.Runtime.InteropServices.WindowsRuntime;
+ using System.Windows;
using System.Xml.Serialization;
+ using HandBrakeWPF.Properties;
+ using HandBrakeWPF.Services.Interfaces;
using HandBrakeWPF.Services.Queue.Model;
using HandBrakeWPF.Utilities;
@@ -53,6 +57,9 @@ namespace HandBrakeWPF.Services.Queue
/// </summary>
private bool clearCompleted;
+ private readonly IUserSettingService userSettingService;
+ private readonly IErrorService errorService;
+
#endregion
#region Constructors and Destructors
@@ -63,11 +70,19 @@ namespace HandBrakeWPF.Services.Queue
/// <param name="encodeService">
/// The encode Service.
/// </param>
+ /// <param name="userSettingService">
+ /// The user settings service.
+ /// </param>
+ /// <param name="errorService">
+ /// The Error Service.
+ /// </param>
/// <exception cref="ArgumentNullException">
/// Services are not setup
/// </exception>
- public QueueProcessor(IEncode encodeService)
+ public QueueProcessor(IEncode encodeService, IUserSettingService userSettingService, IErrorService errorService)
{
+ this.userSettingService = userSettingService;
+ this.errorService = errorService;
this.EncodeService = encodeService;
// If this is the first instance, just use the main queue file, otherwise add the instance id to the filename.
@@ -125,6 +140,8 @@ namespace HandBrakeWPF.Services.Queue
/// </summary>
public event EventHandler QueuePaused;
+ public event EventHandler LowDiskspaceDetected;
+
#endregion
#region Properties
@@ -587,6 +604,11 @@ namespace HandBrakeWPF.Services.Queue
this.IsProcessing = false;
}
+ protected virtual void OnLowDiskspaceDetected()
+ {
+ this.LowDiskspaceDetected?.Invoke(this, EventArgs.Empty);
+ }
+
/// <summary>
/// Run through all the jobs on the queue.
/// </summary>
@@ -595,6 +617,22 @@ namespace HandBrakeWPF.Services.Queue
QueueTask job = this.GetNextJobForProcessing();
if (job != null)
{
+ if (this.userSettingService.GetUserSetting<bool>(UserSettingConstants.PauseOnLowDiskspace))
+ {
+ string drive = Path.GetPathRoot(job.Task.Destination);
+ if (drive != null)
+ {
+ DriveInfo c = new DriveInfo(drive);
+ if (c.AvailableFreeSpace < this.userSettingService.GetUserSetting<long>(UserSettingConstants.PauseOnLowDiskspaceLevel))
+ {
+ job.Status = QueueItemStatus.Waiting;
+ this.InvokeQueueChanged(EventArgs.Empty);
+ this.OnLowDiskspaceDetected();
+ return; // Don't start the next job.
+ }
+ }
+ }
+
this.InvokeJobProcessingStarted(new QueueProgressEventArgs(job));
this.EncodeService.Start(job.Task, job.Configuration);
}
@@ -609,5 +647,6 @@ namespace HandBrakeWPF.Services.Queue
}
#endregion
+
}
} \ No newline at end of file