summaryrefslogtreecommitdiffstats
path: root/win/CS/HandBrakeWPF/Services
diff options
context:
space:
mode:
authorsr55 <[email protected]>2019-05-11 17:24:54 +0100
committersr55 <[email protected]>2019-05-11 17:24:54 +0100
commit4b8c299e283bcce467eebf59248524ed94befa5d (patch)
treedcd5aeca06a1a65c10d76d0fe8ae58298302b26c /win/CS/HandBrakeWPF/Services
parentd66c23d4a81c6165965114e855a4f361c9481649 (diff)
WinGui: More Robust Queue Backup and Recovery.
Diffstat (limited to 'win/CS/HandBrakeWPF/Services')
-rw-r--r--win/CS/HandBrakeWPF/Services/Queue/QueueService.cs15
1 files changed, 12 insertions, 3 deletions
diff --git a/win/CS/HandBrakeWPF/Services/Queue/QueueService.cs b/win/CS/HandBrakeWPF/Services/Queue/QueueService.cs
index 0a9c6e8e9..48c29f4f4 100644
--- a/win/CS/HandBrakeWPF/Services/Queue/QueueService.cs
+++ b/win/CS/HandBrakeWPF/Services/Queue/QueueService.cs
@@ -42,9 +42,6 @@ namespace HandBrakeWPF.Services.Queue
using QueueCompletedEventArgs = HandBrakeWPF.EventArgs.QueueCompletedEventArgs;
using QueueProgressEventArgs = HandBrakeWPF.EventArgs.QueueProgressEventArgs;
- /// <summary>
- /// The HandBrake Queue
- /// </summary>
public class QueueService : Interfaces.IQueueService
{
#region Constants and Fields
@@ -218,6 +215,12 @@ namespace HandBrakeWPF.Services.Queue
? exportPath
: Path.Combine(appDataPath, string.Format(this.queueFile, string.Empty));
+ // Make a copy of the file before we replace it. This way, if we crash we can recover.
+ if (File.Exists(tempPath))
+ {
+ File.Copy(tempPath, tempPath + ".last");
+ }
+
using (StreamWriter writer = new StreamWriter(tempPath))
{
List<QueueTask> tasks = this.queue.Where(item => item.Status != QueueItemStatus.Completed).ToList();
@@ -225,6 +228,11 @@ namespace HandBrakeWPF.Services.Queue
writer.Write(queueJson);
}
+ if (File.Exists(tempPath + ".last"))
+ {
+ File.Delete(tempPath + ".last");
+ }
+
watch.Stop();
Debug.WriteLine("Queue Save (ms): " + watch.ElapsedMilliseconds);
}
@@ -679,6 +687,7 @@ namespace HandBrakeWPF.Services.Queue
this.BackupQueue(string.Empty);
return;
}
+
this.EncodeService.Start(job.Task, job.Configuration);
this.BackupQueue(string.Empty);
}