sync updates

This commit is contained in:
Luke Pulverenti
2015-02-04 15:16:23 -05:00
parent e6ea26e3de
commit 046a1de253
13 changed files with 173 additions and 12 deletions

View File

@@ -174,7 +174,7 @@ namespace MediaBrowser.Server.Implementations.Sync
return returnResult;
}
public Task UpdateJob(SyncJob job)
public async Task UpdateJob(SyncJob job)
{
// Get fresh from the db and only update the fields that are supported to be changed.
var instance = _repo.GetJob(job.Id);
@@ -185,7 +185,21 @@ namespace MediaBrowser.Server.Implementations.Sync
instance.SyncNewContent = job.SyncNewContent;
instance.ItemLimit = job.ItemLimit;
return _repo.Update(instance);
await _repo.Update(instance).ConfigureAwait(false);
OnSyncJobUpdated(instance);
}
internal void OnSyncJobUpdated(SyncJob job)
{
if (SyncJobUpdated != null)
{
EventHelper.FireEventIfNotNull(SyncJobUpdated, this, new GenericEventArgs<SyncJob>
{
Argument = job
}, _logger);
}
}
public async Task<QueryResult<SyncJob>> GetJobs(SyncJobQuery query)
@@ -202,6 +216,14 @@ namespace MediaBrowser.Server.Implementations.Sync
private async Task FillMetadata(SyncJob job)
{
var target = GetSyncTargets(job.UserId)
.FirstOrDefault(i => string.Equals(i.Id, job.TargetId, StringComparison.OrdinalIgnoreCase));
if (target != null)
{
job.TargetName = target.Name;
}
var item = job.RequestedItemIds
.Select(_libraryManager.GetItemById)
.FirstOrDefault(i => i != null);