From 1c64294301cb511a1e088750f810121c4661aabc Mon Sep 17 00:00:00 2001 From: sr55 Date: Sat, 26 Mar 2016 19:13:22 +0000 Subject: WinGui: If there are multiple queue recovery files, don't fail the set if one is bad. Let the rest load normally. --- win/CS/HandBrakeWPF/Helpers/QueueRecoveryHelper.cs | 31 ++++++++++++++-------- 1 file changed, 20 insertions(+), 11 deletions(-) (limited to 'win') diff --git a/win/CS/HandBrakeWPF/Helpers/QueueRecoveryHelper.cs b/win/CS/HandBrakeWPF/Helpers/QueueRecoveryHelper.cs index 143288403..04274e791 100644 --- a/win/CS/HandBrakeWPF/Helpers/QueueRecoveryHelper.cs +++ b/win/CS/HandBrakeWPF/Helpers/QueueRecoveryHelper.cs @@ -11,6 +11,7 @@ namespace HandBrakeWPF.Helpers { using System; using System.Collections.Generic; + using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; @@ -53,23 +54,30 @@ namespace HandBrakeWPF.Helpers IEnumerable logFiles = info.GetFiles("*.xml").Where(f => f.Name.StartsWith("hb_queue_recovery")); foreach (FileInfo file in logFiles) { - using (FileStream strm = new FileStream(file.FullName, FileMode.Open, FileAccess.Read)) + try { - List list = Ser.Deserialize(strm) as List; - if (list != null && list.Count == 0) + using (FileStream strm = new FileStream(file.FullName, FileMode.Open, FileAccess.Read)) { - removeFiles.Add(file.FullName); - } + List list = Ser.Deserialize(strm) as List; + if (list != null && list.Count == 0) + { + removeFiles.Add(file.FullName); + } - if (list != null && list.Count != 0) - { - List tasks = list.Where(l => l.Status != QueueItemStatus.Completed).ToList(); - if (tasks.Count != 0) + if (list != null && list.Count != 0) { - queueFiles.Add(file.Name); + List tasks = list.Where(l => l.Status != QueueItemStatus.Completed).ToList(); + if (tasks.Count != 0) + { + queueFiles.Add(file.Name); + } } } } + catch (Exception exc) + { + Debug.WriteLine(exc); + } } // Cleanup old/unused queue files for now. @@ -90,8 +98,9 @@ namespace HandBrakeWPF.Helpers return queueFiles; } - catch (Exception) + catch (Exception exc) { + Debug.WriteLine(exc); return new List(); // Keep quiet about the error. } } -- cgit v1.2.3