]> granicus.if.org Git - handbrake/commitdiff
WinGui: Fix an issue with multi-instance queue recovery files not being cleared up...
authorsr55 <sr55.hb@outlook.com>
Sun, 29 Jan 2012 13:25:37 +0000 (13:25 +0000)
committersr55 <sr55.hb@outlook.com>
Sun, 29 Jan 2012 13:25:37 +0000 (13:25 +0000)
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@4426 b64f7644-9d1e-0410-96f1-a4d463321fa5

win/CS/Functions/Main.cs
win/CS/HandBrake.ApplicationServices/Services/QueueManager.cs

index db154ab2fc1eb12c5aa07ecf31b288f992995a0d..4de00af9066d4ceb87bebe826636534777369b77 100644 (file)
@@ -397,17 +397,19 @@ namespace Handbrake.Functions
             {\r
                 string tempPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), @"HandBrake\");\r
                 List<string> queueFiles = new List<string>();\r
+                List<string> removeFiles = new List<string>();\r
 \r
                 DirectoryInfo info = new DirectoryInfo(tempPath);\r
-                FileInfo[] logFiles = info.GetFiles("*.xml");\r
+                IEnumerable<FileInfo> logFiles = info.GetFiles("*.xml").Where(f => f.Name.StartsWith("hb_queue_recovery"));\r
                 foreach (FileInfo file in logFiles)\r
                 {\r
-                    if (!file.Name.Contains("hb_queue_recovery"))\r
-                        continue;\r
-\r
-                    using (FileStream strm = new FileStream(Path.Combine(file.DirectoryName, file.Name), FileMode.Open, FileAccess.Read))\r
+                    using (FileStream strm = new FileStream(file.FullName, FileMode.Open, FileAccess.Read))\r
                     {\r
                         List<QueueTask> list = Ser.Deserialize(strm) as List<QueueTask>;\r
+                        if (list != null && list.Count == 0)\r
+                        {\r
+                            removeFiles.Add(file.FullName);\r
+                        }\r
                         \r
                         if (list != null && list.Count != 0)\r
                         {\r
@@ -420,6 +422,12 @@ namespace Handbrake.Functions
                     }\r
                 }\r
 \r
+                // Cleanup old/unused queue files for now.\r
+                foreach (string file in removeFiles)\r
+                {\r
+                    File.Delete(file);\r
+                }\r
+\r
                 return queueFiles;\r
             }\r
             catch (Exception exc)\r
index c138708a7723ff1aa56fa89a5e6575422b11e177..6cddd2707ce628248a614c92e9559cf21a4c44c8 100644 (file)
@@ -315,6 +315,7 @@ namespace HandBrake.ApplicationServices.Services
 \r
             if (File.Exists(tempPath))\r
             {\r
+                bool invokeUpdate = false;\r
                 using (FileStream strm = new FileStream((!string.IsNullOrEmpty(importPath) ? importPath : tempPath), FileMode.Open, FileAccess.Read))\r
                 {\r
                     if (strm.Length != 0)\r
@@ -338,9 +339,14 @@ namespace HandBrake.ApplicationServices.Services
                                 }\r
                             }\r
 \r
-                        this.InvokeQueueChanged(EventArgs.Empty);\r
+                        invokeUpdate = true;\r
                     }\r
                 }\r
+\r
+                if (invokeUpdate)\r
+                {\r
+                    this.InvokeQueueChanged(EventArgs.Empty);\r
+                }\r
             }\r
         }\r
 \r