{\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
}\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
\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
}\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