summaryrefslogtreecommitdiffstats
path: root/win/CS/HandBrakeWPF
diff options
context:
space:
mode:
authorsr55 <[email protected]>2018-04-14 21:06:15 +0100
committersr55 <[email protected]>2018-04-14 21:06:15 +0100
commitf0cad86eb7cc4be937393870559c509cad640172 (patch)
tree5aca4faf9a2062dc88b1a9365d1f9c31f411f8c9 /win/CS/HandBrakeWPF
parent36c1cdc7f0cfd69003d674883021cec3e900abed (diff)
WinGui: New start-up command line option. --recover-queue-ids=<command separated id list> to recover specific queue files on startup.
Diffstat (limited to 'win/CS/HandBrakeWPF')
-rw-r--r--win/CS/HandBrakeWPF/App.xaml.cs15
-rw-r--r--win/CS/HandBrakeWPF/Helpers/QueueRecoveryHelper.cs24
-rw-r--r--win/CS/HandBrakeWPF/Startup/StartupOptions.cs3
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs2
4 files changed, 34 insertions, 10 deletions
diff --git a/win/CS/HandBrakeWPF/App.xaml.cs b/win/CS/HandBrakeWPF/App.xaml.cs
index d9349e567..a3809bea7 100644
--- a/win/CS/HandBrakeWPF/App.xaml.cs
+++ b/win/CS/HandBrakeWPF/App.xaml.cs
@@ -10,6 +10,7 @@
namespace HandBrakeWPF
{
using System;
+ using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Windows;
@@ -17,8 +18,7 @@ namespace HandBrakeWPF
using Caliburn.Micro;
- using HandBrake.ApplicationServices.Utilities;
-
+ using HandBrakeWPF.Helpers;
using HandBrakeWPF.Startup;
using HandBrakeWPF.Utilities;
using HandBrakeWPF.ViewModels;
@@ -74,6 +74,17 @@ namespace HandBrakeWPF
return;
}
+ if (e.Args.Any(f => f.StartsWith("--recover-queue-ids")))
+ {
+ string command = e.Args.FirstOrDefault(f => f.StartsWith("--recover-queue-ids"));
+ if (!string.IsNullOrEmpty(command))
+ {
+ command = command.Replace("--recover-queue-ids=", string.Empty);
+ List<string> processIds = command.Split(',').ToList();
+ StartupOptions.QueueRecoveryIds = processIds;
+ }
+ }
+
if (e.Args.Any(f => f.Equals("--auto-start-queue")))
{
StartupOptions.AutoRestartQueue = true;
diff --git a/win/CS/HandBrakeWPF/Helpers/QueueRecoveryHelper.cs b/win/CS/HandBrakeWPF/Helpers/QueueRecoveryHelper.cs
index 4b9aa4f81..4ce79bec2 100644
--- a/win/CS/HandBrakeWPF/Helpers/QueueRecoveryHelper.cs
+++ b/win/CS/HandBrakeWPF/Helpers/QueueRecoveryHelper.cs
@@ -39,14 +39,14 @@ namespace HandBrakeWPF.Helpers
/// <returns>
/// True if there is a queue to recover.
/// </returns>
- public static List<string> CheckQueueRecovery()
+ public static List<string> CheckQueueRecovery(List<string> filterQueueFiles)
{
try
{
string tempPath = DirectoryUtilities.GetUserStoragePath(VersionHelper.IsNightly());
DirectoryInfo info = new DirectoryInfo(tempPath);
IEnumerable<FileInfo> foundFiles = info.GetFiles("*.xml").Where(f => f.Name.StartsWith("hb_queue_recovery"));
- var queueFiles = GetFilesExcludingActiveProcesses(foundFiles);
+ var queueFiles = GetFilesExcludingActiveProcesses(foundFiles, filterQueueFiles);
if (!queueFiles.Any())
{
@@ -115,10 +115,10 @@ namespace HandBrakeWPF.Helpers
/// <returns>
/// The <see cref="bool"/>.
/// </returns>
- public static bool RecoverQueue(IQueueProcessor encodeQueue, IErrorService errorService, bool silentRecovery)
+ public static bool RecoverQueue(IQueueProcessor encodeQueue, IErrorService errorService, bool silentRecovery, List<string> queueFilter)
{
string appDataPath = DirectoryUtilities.GetUserStoragePath(VersionHelper.IsNightly());
- List<string> queueFiles = CheckQueueRecovery();
+ List<string> queueFiles = CheckQueueRecovery(queueFilter);
MessageBoxResult result = MessageBoxResult.None;
if (!silentRecovery)
{
@@ -166,7 +166,7 @@ namespace HandBrakeWPF.Helpers
return false;
}
- private static List<string> GetFilesExcludingActiveProcesses(IEnumerable<FileInfo> foundFiles)
+ private static List<string> GetFilesExcludingActiveProcesses(IEnumerable<FileInfo> foundFiles, List<string> filterQueueFiles)
{
List<string> queueFiles = new List<string>();
@@ -174,12 +174,22 @@ namespace HandBrakeWPF.Helpers
foreach (FileInfo file in foundFiles)
{
string fileProcessId = file.Name.Replace("hb_queue_recovery", string.Empty).Replace(".xml", string.Empty);
- int processId = 0;
+ int processId;
if (!string.IsNullOrEmpty(fileProcessId) && int.TryParse(fileProcessId, out processId))
{
if (!GeneralUtilities.IsPidACurrentHandBrakeInstance(processId))
{
- queueFiles.Add(file.FullName);
+ if (filterQueueFiles != null && filterQueueFiles.Count > 0)
+ {
+ if (filterQueueFiles.Contains(processId.ToString()))
+ {
+ queueFiles.Add(file.FullName);
+ }
+ }
+ else
+ {
+ queueFiles.Add(file.FullName);
+ }
}
}
}
diff --git a/win/CS/HandBrakeWPF/Startup/StartupOptions.cs b/win/CS/HandBrakeWPF/Startup/StartupOptions.cs
index 98634634e..72a350c3d 100644
--- a/win/CS/HandBrakeWPF/Startup/StartupOptions.cs
+++ b/win/CS/HandBrakeWPF/Startup/StartupOptions.cs
@@ -9,6 +9,8 @@
namespace HandBrakeWPF.Startup
{
+ using System.Collections.Generic;
+
/// <summary>
/// The startup options.
/// </summary>
@@ -18,5 +20,6 @@ namespace HandBrakeWPF.Startup
/// Gets or sets a value indicating whether auto restart queue.
/// </summary>
public static bool AutoRestartQueue { get; set; }
+ public static List<string> QueueRecoveryIds { get; set; }
}
}
diff --git a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs
index 76e3c026e..8b1eb22e6 100644
--- a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs
+++ b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs
@@ -1254,7 +1254,7 @@ namespace HandBrakeWPF.ViewModels
this.SummaryViewModel.OutputFormatChanged += this.SummaryViewModel_OutputFormatChanged;
// Queue Recovery
- bool queueRecovered = QueueRecoveryHelper.RecoverQueue(this.queueProcessor, this.errorService, StartupOptions.AutoRestartQueue);
+ bool queueRecovered = QueueRecoveryHelper.RecoverQueue(this.queueProcessor, this.errorService, StartupOptions.AutoRestartQueue, StartupOptions.QueueRecoveryIds);
// If the queue is not recovered, show the source selection window by default.
if (!queueRecovered)