handle non-existent user with sync jobs

This commit is contained in:
Luke Pulverenti 2016-12-30 16:14:21 -05:00
parent b8f57f586b
commit 1dea300f6b
2 changed files with 12 additions and 10 deletions

View file

@ -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.Sync
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);
}
}
}
}

View file

@ -181,7 +181,7 @@ namespace Emby.Server.Implementations.Sync
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
var jobItemsResult = GetJobItems(new SyncJobItemQuery