summaryrefslogtreecommitdiffstats
path: root/win/CS/HandBrakeWPF/Services
diff options
context:
space:
mode:
authorsr55 <[email protected]>2020-02-12 22:12:48 +0000
committersr55 <[email protected]>2020-02-12 22:12:48 +0000
commit0979767b3fbf33838e9012b4f28e36a57e5e37e2 (patch)
tree4238cecbc193c51c8f5d85d0fdaeae9560631812 /win/CS/HandBrakeWPF/Services
parent7adb00bcc87d27bf7c484e848fa8844b4913c3f9 (diff)
WinGui: Changed the behaviour of the Queue Import. Now, if duplicates are detected on import, the user will be given the choice to overwrite the existing records. If not overwriting, queue tasks will NOT be imported. #2632
Diffstat (limited to 'win/CS/HandBrakeWPF/Services')
-rw-r--r--win/CS/HandBrakeWPF/Services/Queue/Model/QueueTask.cs5
-rw-r--r--win/CS/HandBrakeWPF/Services/Queue/QueueService.cs33
2 files changed, 37 insertions, 1 deletions
diff --git a/win/CS/HandBrakeWPF/Services/Queue/Model/QueueTask.cs b/win/CS/HandBrakeWPF/Services/Queue/Model/QueueTask.cs
index 52a77f714..3ee126ce9 100644
--- a/win/CS/HandBrakeWPF/Services/Queue/Model/QueueTask.cs
+++ b/win/CS/HandBrakeWPF/Services/Queue/Model/QueueTask.cs
@@ -9,6 +9,7 @@
namespace HandBrakeWPF.Services.Queue.Model
{
+ using System;
using System.Runtime.CompilerServices;
using Caliburn.Micro;
@@ -55,8 +56,12 @@ namespace HandBrakeWPF.Services.Queue.Model
this.Id = string.Format("{0}.{1}", GeneralUtilities.ProcessId, id);
this.Statistics = new QueueStats();
+ this.TaskId = Guid.NewGuid().ToString();
}
+ [JsonProperty]
+ public string TaskId { get; set; }
+
[JsonIgnore]
public string Id { get; }
diff --git a/win/CS/HandBrakeWPF/Services/Queue/QueueService.cs b/win/CS/HandBrakeWPF/Services/Queue/QueueService.cs
index 9e1c37bc9..25abbd53a 100644
--- a/win/CS/HandBrakeWPF/Services/Queue/QueueService.cs
+++ b/win/CS/HandBrakeWPF/Services/Queue/QueueService.cs
@@ -16,6 +16,7 @@ namespace HandBrakeWPF.Services.Queue
using System.Diagnostics;
using System.IO;
using System.Linq;
+ using System.Windows;
using System.Windows.Media.Imaging;
using HandBrake.Interop.Interop.Json.Queue;
@@ -47,14 +48,17 @@ namespace HandBrakeWPF.Services.Queue
private static readonly object QueueLock = new object();
private readonly IUserSettingService userSettingService;
private readonly ILog logService;
+ private readonly IErrorService errorService;
+
private readonly ObservableCollection<QueueTask> queue = new ObservableCollection<QueueTask>();
private readonly string queueFile;
private bool clearCompleted;
- public QueueService(IEncode encodeService, IUserSettingService userSettingService, ILog logService)
+ public QueueService(IEncode encodeService, IUserSettingService userSettingService, ILog logService, IErrorService errorService)
{
this.userSettingService = userSettingService;
this.logService = logService;
+ this.errorService = errorService;
this.EncodeService = encodeService;
// If this is the first instance, just use the main queue file, otherwise add the instance id to the filename.
@@ -193,8 +197,34 @@ namespace HandBrakeWPF.Services.Queue
return;
}
+ List<QueueTask> duplicates = queue.Where(task => reloadedQueue.Any(queueTask => queueTask.TaskId == task.TaskId)).ToList();
+ bool replaceDuplicates = false;
+ if (duplicates.Any())
+ {
+ MessageBoxResult result = this.errorService.ShowMessageBox(
+ Properties.Resources.QueueService_DuplicatesQuestion,
+ Properties.Resources.QueueService_DuplicatesTitle,
+ MessageBoxButton.YesNo,
+ MessageBoxImage.Question);
+
+ if (result == MessageBoxResult.Yes)
+ {
+ foreach (QueueTask task in duplicates)
+ {
+ this.queue.Remove(task);
+ }
+
+ replaceDuplicates = true;
+ }
+ }
+
foreach (QueueTask task in reloadedQueue)
{
+ if (!replaceDuplicates && this.queue.Any(s => s.TaskId == task.TaskId))
+ {
+ continue;
+ }
+
this.queue.Add(task);
}
@@ -205,6 +235,7 @@ namespace HandBrakeWPF.Services.Queue
}
}
+
public bool CheckForDestinationPathDuplicates(string destination)
{
foreach (QueueTask job in this.queue)