summaryrefslogtreecommitdiffstats
path: root/win
diff options
context:
space:
mode:
authorsr55 <[email protected]>2012-01-29 13:25:37 +0000
committersr55 <[email protected]>2012-01-29 13:25:37 +0000
commitbd0a4e453ec01a9b12c7600d0c3aa62e0a797ca2 (patch)
tree3076e99a9545de0c62a0b99f18b622ddc4538116 /win
parentdf4a57b120d44b029538c903491db6e8797cd98c (diff)
WinGui: Fix an issue with multi-instance queue recovery files not being cleared up properly.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@4426 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win')
-rw-r--r--win/CS/Functions/Main.cs18
-rw-r--r--win/CS/HandBrake.ApplicationServices/Services/QueueManager.cs8
2 files changed, 20 insertions, 6 deletions
diff --git a/win/CS/Functions/Main.cs b/win/CS/Functions/Main.cs
index db154ab2f..4de00af90 100644
--- a/win/CS/Functions/Main.cs
+++ b/win/CS/Functions/Main.cs
@@ -397,17 +397,19 @@ namespace Handbrake.Functions
{
string tempPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), @"HandBrake\");
List<string> queueFiles = new List<string>();
+ List<string> removeFiles = new List<string>();
DirectoryInfo info = new DirectoryInfo(tempPath);
- FileInfo[] logFiles = info.GetFiles("*.xml");
+ IEnumerable<FileInfo> logFiles = info.GetFiles("*.xml").Where(f => f.Name.StartsWith("hb_queue_recovery"));
foreach (FileInfo file in logFiles)
{
- if (!file.Name.Contains("hb_queue_recovery"))
- continue;
-
- using (FileStream strm = new FileStream(Path.Combine(file.DirectoryName, file.Name), FileMode.Open, FileAccess.Read))
+ using (FileStream strm = new FileStream(file.FullName, FileMode.Open, FileAccess.Read))
{
List<QueueTask> list = Ser.Deserialize(strm) as List<QueueTask>;
+ if (list != null && list.Count == 0)
+ {
+ removeFiles.Add(file.FullName);
+ }
if (list != null && list.Count != 0)
{
@@ -420,6 +422,12 @@ namespace Handbrake.Functions
}
}
+ // Cleanup old/unused queue files for now.
+ foreach (string file in removeFiles)
+ {
+ File.Delete(file);
+ }
+
return queueFiles;
}
catch (Exception exc)
diff --git a/win/CS/HandBrake.ApplicationServices/Services/QueueManager.cs b/win/CS/HandBrake.ApplicationServices/Services/QueueManager.cs
index c138708a7..6cddd2707 100644
--- a/win/CS/HandBrake.ApplicationServices/Services/QueueManager.cs
+++ b/win/CS/HandBrake.ApplicationServices/Services/QueueManager.cs
@@ -315,6 +315,7 @@ namespace HandBrake.ApplicationServices.Services
if (File.Exists(tempPath))
{
+ bool invokeUpdate = false;
using (FileStream strm = new FileStream((!string.IsNullOrEmpty(importPath) ? importPath : tempPath), FileMode.Open, FileAccess.Read))
{
if (strm.Length != 0)
@@ -338,9 +339,14 @@ namespace HandBrake.ApplicationServices.Services
}
}
- this.InvokeQueueChanged(EventArgs.Empty);
+ invokeUpdate = true;
}
}
+
+ if (invokeUpdate)
+ {
+ this.InvokeQueueChanged(EventArgs.Empty);
+ }
}
}