]> granicus.if.org Git - handbrake/commitdiff
WinGui: New start-up command line option. --recover-queue-ids=<command separated...
authorsr55 <sr55.hb@outlook.com>
Sat, 14 Apr 2018 20:06:15 +0000 (21:06 +0100)
committersr55 <sr55.hb@outlook.com>
Sat, 14 Apr 2018 20:06:15 +0000 (21:06 +0100)
win/CS/HandBrakeWPF/App.xaml.cs
win/CS/HandBrakeWPF/Helpers/QueueRecoveryHelper.cs
win/CS/HandBrakeWPF/Startup/StartupOptions.cs
win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs

index d9349e567ae73f2d50133fbe4f5409edca84e211..a3809bea75181da2c0bab6442910c6fe466a9fc6 100644 (file)
@@ -10,6 +10,7 @@
 namespace HandBrakeWPF\r
 {\r
     using System;\r
+    using System.Collections.Generic;\r
     using System.IO;\r
     using System.Linq;\r
     using System.Windows;\r
@@ -17,8 +18,7 @@ namespace HandBrakeWPF
 \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
@@ -74,6 +74,17 @@ namespace HandBrakeWPF
                 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
index 4b9aa4f81ebae0092927526a78a12ed2d4d061ba..4ce79bec23bbe1b0cf819f541d928f3e235a56ad 100644 (file)
@@ -39,14 +39,14 @@ namespace HandBrakeWPF.Helpers
         /// <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
@@ -115,10 +115,10 @@ namespace HandBrakeWPF.Helpers
         /// <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
@@ -166,7 +166,7 @@ namespace HandBrakeWPF.Helpers
             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
@@ -174,12 +174,22 @@ namespace HandBrakeWPF.Helpers
             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
index 98634634e5e2e0fa545d32f34265184c6ff1b554..72a350c3d021e73934c01b8ffe6a13214af63d48 100644 (file)
@@ -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; }
     }
 }
index 76e3c026e1508677f71694e6fc8a6946737ad2a0..8b1eb22e6cd385ad6e597dfff76cb2997d282cff 100644 (file)
@@ -1254,7 +1254,7 @@ namespace HandBrakeWPF.ViewModels
             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