namespace HandBrakeWPF\r
{\r
using System;\r
+ using System.Collections.Generic;\r
using System.IO;\r
using System.Linq;\r
using System.Windows;\r
\r
using Caliburn.Micro;\r
\r
- using HandBrake.ApplicationServices.Utilities;\r
-\r
+ using HandBrakeWPF.Helpers;\r
using HandBrakeWPF.Startup;\r
using HandBrakeWPF.Utilities;\r
using HandBrakeWPF.ViewModels;\r
return;\r
}\r
\r
+ if (e.Args.Any(f => f.StartsWith("--recover-queue-ids")))\r
+ {\r
+ string command = e.Args.FirstOrDefault(f => f.StartsWith("--recover-queue-ids"));\r
+ if (!string.IsNullOrEmpty(command))\r
+ {\r
+ command = command.Replace("--recover-queue-ids=", string.Empty);\r
+ List<string> processIds = command.Split(',').ToList();\r
+ StartupOptions.QueueRecoveryIds = processIds;\r
+ }\r
+ }\r
+ \r
if (e.Args.Any(f => f.Equals("--auto-start-queue")))\r
{\r
StartupOptions.AutoRestartQueue = true;\r
/// <returns>\r
/// True if there is a queue to recover.\r
/// </returns>\r
- public static List<string> CheckQueueRecovery()\r
+ public static List<string> CheckQueueRecovery(List<string> filterQueueFiles)\r
{\r
try\r
{\r
string tempPath = DirectoryUtilities.GetUserStoragePath(VersionHelper.IsNightly());\r
DirectoryInfo info = new DirectoryInfo(tempPath);\r
IEnumerable<FileInfo> foundFiles = info.GetFiles("*.xml").Where(f => f.Name.StartsWith("hb_queue_recovery"));\r
- var queueFiles = GetFilesExcludingActiveProcesses(foundFiles);\r
+ var queueFiles = GetFilesExcludingActiveProcesses(foundFiles, filterQueueFiles);\r
\r
if (!queueFiles.Any())\r
{\r
/// <returns>\r
/// The <see cref="bool"/>.\r
/// </returns>\r
- public static bool RecoverQueue(IQueueProcessor encodeQueue, IErrorService errorService, bool silentRecovery)\r
+ public static bool RecoverQueue(IQueueProcessor encodeQueue, IErrorService errorService, bool silentRecovery, List<string> queueFilter)\r
{\r
string appDataPath = DirectoryUtilities.GetUserStoragePath(VersionHelper.IsNightly());\r
- List<string> queueFiles = CheckQueueRecovery();\r
+ List<string> queueFiles = CheckQueueRecovery(queueFilter);\r
MessageBoxResult result = MessageBoxResult.None;\r
if (!silentRecovery)\r
{\r
return false;\r
}\r
\r
- private static List<string> GetFilesExcludingActiveProcesses(IEnumerable<FileInfo> foundFiles)\r
+ private static List<string> GetFilesExcludingActiveProcesses(IEnumerable<FileInfo> foundFiles, List<string> filterQueueFiles)\r
{\r
List<string> queueFiles = new List<string>();\r
\r
foreach (FileInfo file in foundFiles)\r
{\r
string fileProcessId = file.Name.Replace("hb_queue_recovery", string.Empty).Replace(".xml", string.Empty);\r
- int processId = 0;\r
+ int processId;\r
if (!string.IsNullOrEmpty(fileProcessId) && int.TryParse(fileProcessId, out processId))\r
{\r
if (!GeneralUtilities.IsPidACurrentHandBrakeInstance(processId))\r
{\r
- queueFiles.Add(file.FullName);\r
+ if (filterQueueFiles != null && filterQueueFiles.Count > 0)\r
+ {\r
+ if (filterQueueFiles.Contains(processId.ToString()))\r
+ {\r
+ queueFiles.Add(file.FullName);\r
+ }\r
+ }\r
+ else\r
+ {\r
+ queueFiles.Add(file.FullName);\r
+ } \r
}\r
}\r
}\r
this.SummaryViewModel.OutputFormatChanged += this.SummaryViewModel_OutputFormatChanged;\r
\r
// Queue Recovery\r
- bool queueRecovered = QueueRecoveryHelper.RecoverQueue(this.queueProcessor, this.errorService, StartupOptions.AutoRestartQueue);\r
+ bool queueRecovered = QueueRecoveryHelper.RecoverQueue(this.queueProcessor, this.errorService, StartupOptions.AutoRestartQueue, StartupOptions.QueueRecoveryIds);\r
\r
// If the queue is not recovered, show the source selection window by default.\r
if (!queueRecovered)\r