diff options
author | sr55 <[email protected]> | 2017-05-27 19:46:55 +0100 |
---|---|---|
committer | sr55 <[email protected]> | 2017-05-27 19:47:08 +0100 |
commit | 05faa1f855472e8783905b7fa2a8ce1ad4267722 (patch) | |
tree | f7b786b7acd59a92a55c317cd2caf7b39557a481 /win/CS/HandBrakeWPF/Services | |
parent | d9c418e08089da33d6580cdba32439866fb12924 (diff) |
WinGui: Add a log message whent he queue is paused due to low disk space. Improve handling of automated queue pausing. #748
Diffstat (limited to 'win/CS/HandBrakeWPF/Services')
-rw-r--r-- | win/CS/HandBrakeWPF/Services/Queue/Interfaces/IQueueProcessor.cs | 8 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/Services/Queue/QueueProcessor.cs | 42 |
2 files changed, 13 insertions, 37 deletions
diff --git a/win/CS/HandBrakeWPF/Services/Queue/Interfaces/IQueueProcessor.cs b/win/CS/HandBrakeWPF/Services/Queue/Interfaces/IQueueProcessor.cs index ffc9107bb..ead10cbf3 100644 --- a/win/CS/HandBrakeWPF/Services/Queue/Interfaces/IQueueProcessor.cs +++ b/win/CS/HandBrakeWPF/Services/Queue/Interfaces/IQueueProcessor.cs @@ -14,7 +14,7 @@ namespace HandBrakeWPF.Services.Queue.Interfaces using HandBrakeWPF.Services.Queue.Model;
- using IEncode = HandBrakeWPF.Services.Encode.Interfaces.IEncode;
+ using IEncode = Encode.Interfaces.IEncode;
/// <summary>
/// The Queue Processor
@@ -44,12 +44,6 @@ 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 f0425b0c0..2292d18a2 100644 --- a/win/CS/HandBrakeWPF/Services/Queue/QueueProcessor.cs +++ b/win/CS/HandBrakeWPF/Services/Queue/QueueProcessor.cs @@ -17,9 +17,12 @@ namespace HandBrakeWPF.Services.Queue using System.Xml.Serialization;
using HandBrake.ApplicationServices.Model;
+ using HandBrake.ApplicationServices.Services.Logging;
+ using HandBrake.ApplicationServices.Services.Logging.Model;
using HandBrake.ApplicationServices.Utilities;
using HandBrakeWPF.Factories;
+ using HandBrakeWPF.Properties;
using HandBrakeWPF.Services.Encode.Factories;
using HandBrakeWPF.Services.Encode.Model;
using HandBrakeWPF.Services.Interfaces;
@@ -130,11 +133,6 @@ namespace HandBrakeWPF.Services.Queue /// </summary>
public event EventHandler QueuePaused;
- /// <summary>
- /// The low diskspace detected.
- /// </summary>
- public event EventHandler LowDiskspaceDetected;
-
#endregion
#region Properties
@@ -478,8 +476,8 @@ namespace HandBrakeWPF.Services.Queue /// </summary>
public void Pause()
{
- this.InvokeQueuePaused(EventArgs.Empty);
this.IsProcessing = false;
+ this.InvokeQueuePaused(EventArgs.Empty);
}
/// <summary>
@@ -501,17 +499,16 @@ namespace HandBrakeWPF.Services.Queue this.EncodeService.EncodeCompleted -= this.EncodeServiceEncodeCompleted;
this.EncodeService.EncodeCompleted += this.EncodeServiceEncodeCompleted;
- if (this.EncodeService.IsEncoding)
+ if (this.EncodeService.IsPasued)
{
this.EncodeService.Resume();
+ this.IsProcessing = true;
}
if (!this.EncodeService.IsEncoding)
{
this.ProcessNextJob();
}
-
- this.IsProcessing = true;
}
#endregion
@@ -536,14 +533,6 @@ namespace HandBrakeWPF.Services.Queue }
/// <summary>
- /// The on low diskspace detected.
- /// </summary>
- protected virtual void OnLowDiskspaceDetected()
- {
- this.LowDiskspaceDetected?.Invoke(this, EventArgs.Empty);
- }
-
- /// <summary>
/// After an encode is complete, move onto the next job.
/// </summary>
/// <param name="sender">
@@ -644,22 +633,15 @@ namespace HandBrakeWPF.Services.Queue QueueTask job = this.GetNextJobForProcessing();
if (job != null)
{
- if (this.userSettingService.GetUserSetting<bool>(UserSettingConstants.PauseOnLowDiskspace))
+ if (this.userSettingService.GetUserSetting<bool>(UserSettingConstants.PauseOnLowDiskspace) && !DriveUtilities.HasMinimumDiskSpace(job.Task.Destination, this.userSettingService.GetUserSetting<long>(UserSettingConstants.PauseOnLowDiskspaceLevel)))
{
- string drive = Path.GetPathRoot(job.Task.Destination);
- if (!string.IsNullOrEmpty(drive) && !drive.StartsWith("\\"))
- {
- 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.
- }
- }
+ LogService.GetLogger().LogMessage(Resources.PauseOnLowDiskspace, LogMessageType.ScanOrEncode, LogLevel.Info);
+ job.Status = QueueItemStatus.Waiting;
+ this.Pause();
+ return; // Don't start the next job.
}
+ this.IsProcessing = true;
this.InvokeJobProcessingStarted(new QueueProgressEventArgs(job));
this.EncodeService.Start(job.Task, job.Configuration);
}
|