handle non-existent user with sync jobs

pull/1154/head
Luke Pulverenti 8 years ago
parent b8f57f586b
commit 1dea300f6b

@ -59,15 +59,8 @@ namespace Emby.Server.Implementations.Sync
_mediaSourceManager = mediaSourceManager; _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)) var items = (await GetItemsForSync(job.Category, job.ParentId, job.RequestedItemIds, user, job.UnwatchedOnly).ConfigureAwait(false))
.ToList(); .ToList();
@ -385,7 +378,16 @@ namespace Emby.Server.Implementations.Sync
if (job.SyncNewContent) if (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);
}
} }
} }
} }

@ -181,7 +181,7 @@ namespace Emby.Server.Implementations.Sync
await _repo.Create(job).ConfigureAwait(false); await _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 conversion // If it already has a converting status then is must have been aborted during conversion
var jobItemsResult = GetJobItems(new SyncJobItemQuery var jobItemsResult = GetJobItems(new SyncJobItemQuery

Loading…
Cancel
Save