The Free Software Media System - Server Backend & API
handle non-existent user with sync jobs
Luke Pulverenti1dea300f6ba8
diff --git a/Emby.Server.Implementations/Sync/SyncJobProcessor.cs b/Emby.Server.Implementations/Sync/SyncJobProcessor.csindex b1adc64df6..17cdef5fcd 100644--- a/Emby.Server.Implementations/Sync/SyncJobProcessor.cs+++ b/Emby.Server.Implementations/Sync/SyncJobProcessor.cs@@ -59,15 +59,8 @@ namespace Emby.Server.Implementations.Sync_mediaSourceManager = mediaSourceManager;}- public async Task EnsureJobItems(SyncJob job)+ public async Task EnsureJobItems(SyncJob job, User user){- var user = _userManager.GetUserById(job.UserId);-- if (user == null)- {- throw new InvalidOperationException("Cannot proceed with sync because user no longer exists.");- }-var items = (await GetItemsForSync(job.Category, job.ParentId, job.RequestedItemIds, user, job.UnwatchedOnly).ConfigureAwait(false)).ToList();@@ -385,7 +378,16 @@ namespace Emby.Server.Implementations.Syncif (job.SyncNewContent){- await EnsureJobItems(job).ConfigureAwait(false);+ var user = _userManager.GetUserById(job.UserId);++ if (user == null)+ {+ await _syncManager.CancelJob(job.Id).ConfigureAwait(false);+ }+ else+ {+ await EnsureJobItems(job, user).ConfigureAwait(false);+ }}}}diff --git a/Emby.Server.Implementations/Sync/SyncManager.cs b/Emby.Server.Implementations/Sync/SyncManager.csindex 310b35afe3..2687eaefc1 100644--- a/Emby.Server.Implementations/Sync/SyncManager.cs+++ b/Emby.Server.Implementations/Sync/SyncManager.cs@@ -181,7 +181,7 @@ namespace Emby.Server.Implementations.Syncawait _repo.Create(job).ConfigureAwait(false);- await processor.EnsureJobItems(job).ConfigureAwait(false);+ await processor.EnsureJobItems(job, user).ConfigureAwait(false);// If it already has a converting status then is must have been aborted during conversionvar jobItemsResult = GetJobItems(new SyncJobItemQuery