From 5e4bf3c36f31bc60a547937b107d0bb61968b9d6 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Wed, 28 Dec 2016 14:56:16 -0500 Subject: [PATCH] add sync error handling --- Emby.Server.Implementations/Sync/SyncJobProcessor.cs | 10 +++++++++- Emby.Server.Implementations/Sync/SyncManager.cs | 5 ----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/Emby.Server.Implementations/Sync/SyncJobProcessor.cs b/Emby.Server.Implementations/Sync/SyncJobProcessor.cs index 415757609..b1adc64df 100644 --- a/Emby.Server.Implementations/Sync/SyncJobProcessor.cs +++ b/Emby.Server.Implementations/Sync/SyncJobProcessor.cs @@ -515,8 +515,14 @@ namespace Emby.Server.Implementations.Sync jobItem.Progress = 0; - var syncOptions = _config.GetSyncOptions(); var job = _syncManager.GetJob(jobItem.JobId); + if (job == null) + { + _logger.Error("Job not found. Cannot complete the sync job."); + await _syncManager.CancelJobItem(jobItem.Id).ConfigureAwait(false); + return; + } + var user = _userManager.GetUserById(job.UserId); if (user == null) { @@ -552,6 +558,8 @@ namespace Emby.Server.Implementations.Sync } } + var syncOptions = _config.GetSyncOptions(); + var video = item as Video; if (video != null) { diff --git a/Emby.Server.Implementations/Sync/SyncManager.cs b/Emby.Server.Implementations/Sync/SyncManager.cs index d3b6b33a2..310b35afe 100644 --- a/Emby.Server.Implementations/Sync/SyncManager.cs +++ b/Emby.Server.Implementations/Sync/SyncManager.cs @@ -1049,11 +1049,6 @@ namespace Emby.Server.Implementations.Sync { var jobItem = _repo.GetJobItem(id); - if (jobItem.Status != SyncJobItemStatus.Queued && jobItem.Status != SyncJobItemStatus.ReadyToTransfer && jobItem.Status != SyncJobItemStatus.Converting && jobItem.Status != SyncJobItemStatus.Failed && jobItem.Status != SyncJobItemStatus.Synced && jobItem.Status != SyncJobItemStatus.Transferring) - { - throw new ArgumentException("Operation is not valid for this job item"); - } - jobItem.Status = SyncJobItemStatus.Cancelled; jobItem.Progress = 0;