fixes #1261 - Sync quality cannot be changed
This commit is contained in:
parent
81d9ea05f6
commit
bfc8facc60
|
@ -149,16 +149,6 @@ namespace MediaBrowser.Server.Implementations.Sync
|
|||
{
|
||||
var job = _syncRepo.GetJob(id);
|
||||
|
||||
return UpdateJobStatus(job);
|
||||
}
|
||||
|
||||
private Task UpdateJobStatus(SyncJob job)
|
||||
{
|
||||
if (job == null)
|
||||
{
|
||||
throw new ArgumentNullException("job");
|
||||
}
|
||||
|
||||
var result = _syncManager.GetJobItems(new SyncJobItemQuery
|
||||
{
|
||||
JobId = job.Id,
|
||||
|
@ -476,14 +466,12 @@ namespace MediaBrowser.Server.Implementations.Sync
|
|||
|
||||
if (jobItem != null)
|
||||
{
|
||||
var job = _syncRepo.GetJob(jobItem.JobId);
|
||||
if (jobItem.Status != SyncJobItemStatus.Cancelled)
|
||||
{
|
||||
await ProcessJobItem(job, jobItem, enableConversion, innerProgress, cancellationToken).ConfigureAwait(false);
|
||||
await ProcessJobItem(jobItem, enableConversion, innerProgress, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
job = _syncRepo.GetJob(jobItem.JobId);
|
||||
await UpdateJobStatus(job).ConfigureAwait(false);
|
||||
await UpdateJobStatus(jobItem.JobId).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
numComplete++;
|
||||
|
@ -493,7 +481,7 @@ namespace MediaBrowser.Server.Implementations.Sync
|
|||
}
|
||||
}
|
||||
|
||||
private async Task ProcessJobItem(SyncJob job, SyncJobItem jobItem, bool enableConversion, IProgress<double> progress, CancellationToken cancellationToken)
|
||||
private async Task ProcessJobItem(SyncJobItem jobItem, bool enableConversion, IProgress<double> progress, CancellationToken cancellationToken)
|
||||
{
|
||||
var item = _libraryManager.GetItemById(jobItem.ItemId);
|
||||
if (item == null)
|
||||
|
@ -507,6 +495,7 @@ namespace MediaBrowser.Server.Implementations.Sync
|
|||
jobItem.Progress = 0;
|
||||
|
||||
var syncOptions = _config.GetSyncOptions();
|
||||
var job = _syncManager.GetJob(jobItem.JobId);
|
||||
var user = _userManager.GetUserById(job.UserId);
|
||||
if (user == null)
|
||||
{
|
||||
|
@ -521,7 +510,7 @@ namespace MediaBrowser.Server.Implementations.Sync
|
|||
{
|
||||
AddMetadata = false,
|
||||
ItemId = jobItem.ItemId,
|
||||
TargetId = job.TargetId,
|
||||
TargetId = jobItem.TargetId,
|
||||
Statuses = new[] { SyncJobItemStatus.Converting, SyncJobItemStatus.Queued, SyncJobItemStatus.ReadyToTransfer, SyncJobItemStatus.Synced, SyncJobItemStatus.Transferring }
|
||||
});
|
||||
|
||||
|
@ -531,7 +520,7 @@ namespace MediaBrowser.Server.Implementations.Sync
|
|||
|
||||
if (duplicateJobItems.Count > 0)
|
||||
{
|
||||
var syncProvider = _syncManager.GetSyncProvider(jobItem, job) as IHasDuplicateCheck;
|
||||
var syncProvider = _syncManager.GetSyncProvider(jobItem) as IHasDuplicateCheck;
|
||||
|
||||
if (!duplicateJobItems.Any(i => AllowDuplicateJobItem(syncProvider, i, jobItem)))
|
||||
{
|
||||
|
@ -545,12 +534,12 @@ namespace MediaBrowser.Server.Implementations.Sync
|
|||
var video = item as Video;
|
||||
if (video != null)
|
||||
{
|
||||
await Sync(jobItem, job, video, user, enableConversion, syncOptions, progress, cancellationToken).ConfigureAwait(false);
|
||||
await Sync(jobItem, video, user, enableConversion, syncOptions, progress, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
else if (item is Audio)
|
||||
{
|
||||
await Sync(jobItem, job, (Audio)item, user, enableConversion, syncOptions, progress, cancellationToken).ConfigureAwait(false);
|
||||
await Sync(jobItem, (Audio)item, user, enableConversion, syncOptions, progress, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
else if (item is Photo)
|
||||
|
@ -574,8 +563,9 @@ namespace MediaBrowser.Server.Implementations.Sync
|
|||
return true;
|
||||
}
|
||||
|
||||
private async Task Sync(SyncJobItem jobItem, SyncJob job, Video item, User user, bool enableConversion, SyncOptions syncOptions, IProgress<double> progress, CancellationToken cancellationToken)
|
||||
private async Task Sync(SyncJobItem jobItem, Video item, User user, bool enableConversion, SyncOptions syncOptions, IProgress<double> progress, CancellationToken cancellationToken)
|
||||
{
|
||||
var job = _syncManager.GetJob(jobItem.JobId);
|
||||
var jobOptions = _syncManager.GetVideoOptions(jobItem, job);
|
||||
var conversionOptions = new VideoOptions
|
||||
{
|
||||
|
@ -616,7 +606,7 @@ namespace MediaBrowser.Server.Implementations.Sync
|
|||
{
|
||||
// Save the job item now since conversion could take a while
|
||||
await _syncManager.UpdateSyncJobItemInternal(jobItem).ConfigureAwait(false);
|
||||
await UpdateJobStatus(job).ConfigureAwait(false);
|
||||
await UpdateJobStatus(jobItem.JobId).ConfigureAwait(false);
|
||||
|
||||
try
|
||||
{
|
||||
|
@ -630,7 +620,7 @@ namespace MediaBrowser.Server.Implementations.Sync
|
|||
{
|
||||
jobItem.Progress = pct / 2;
|
||||
await _syncManager.UpdateSyncJobItemInternal(jobItem).ConfigureAwait(false);
|
||||
await UpdateJobStatus(job).ConfigureAwait(false);
|
||||
await UpdateJobStatus(jobItem.JobId).ConfigureAwait(false);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -642,7 +632,7 @@ namespace MediaBrowser.Server.Implementations.Sync
|
|||
|
||||
}, innerProgress, cancellationToken);
|
||||
|
||||
_syncManager.OnConversionComplete(jobItem, job);
|
||||
_syncManager.OnConversionComplete(jobItem);
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
|
@ -775,8 +765,9 @@ namespace MediaBrowser.Server.Implementations.Sync
|
|||
|
||||
private const int DatabaseProgressUpdateIntervalSeconds = 2;
|
||||
|
||||
private async Task Sync(SyncJobItem jobItem, SyncJob job, Audio item, User user, bool enableConversion, SyncOptions syncOptions, IProgress<double> progress, CancellationToken cancellationToken)
|
||||
private async Task Sync(SyncJobItem jobItem, Audio item, User user, bool enableConversion, SyncOptions syncOptions, IProgress<double> progress, CancellationToken cancellationToken)
|
||||
{
|
||||
var job = _syncManager.GetJob(jobItem.JobId);
|
||||
var jobOptions = _syncManager.GetAudioOptions(jobItem, job);
|
||||
var conversionOptions = new AudioOptions
|
||||
{
|
||||
|
@ -803,7 +794,7 @@ namespace MediaBrowser.Server.Implementations.Sync
|
|||
|
||||
jobItem.Status = SyncJobItemStatus.Converting;
|
||||
await _syncManager.UpdateSyncJobItemInternal(jobItem).ConfigureAwait(false);
|
||||
await UpdateJobStatus(job).ConfigureAwait(false);
|
||||
await UpdateJobStatus(jobItem.JobId).ConfigureAwait(false);
|
||||
|
||||
try
|
||||
{
|
||||
|
@ -817,7 +808,7 @@ namespace MediaBrowser.Server.Implementations.Sync
|
|||
{
|
||||
jobItem.Progress = pct / 2;
|
||||
await _syncManager.UpdateSyncJobItemInternal(jobItem).ConfigureAwait(false);
|
||||
await UpdateJobStatus(job).ConfigureAwait(false);
|
||||
await UpdateJobStatus(jobItem.JobId).ConfigureAwait(false);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -828,7 +819,7 @@ namespace MediaBrowser.Server.Implementations.Sync
|
|||
|
||||
}, innerProgress, cancellationToken);
|
||||
|
||||
_syncManager.OnConversionComplete(jobItem, job);
|
||||
_syncManager.OnConversionComplete(jobItem);
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
|
|
|
@ -1117,7 +1117,7 @@ namespace MediaBrowser.Server.Implementations.Sync
|
|||
public SyncJobOptions GetAudioOptions(SyncJobItem jobItem, SyncJob job)
|
||||
{
|
||||
var options = GetSyncJobOptions(jobItem.TargetId, null, null);
|
||||
|
||||
|
||||
if (job.Bitrate.HasValue)
|
||||
{
|
||||
options.DeviceProfile.MaxStaticBitrate = job.Bitrate.Value;
|
||||
|
@ -1126,7 +1126,7 @@ namespace MediaBrowser.Server.Implementations.Sync
|
|||
return options;
|
||||
}
|
||||
|
||||
public ISyncProvider GetSyncProvider(SyncJobItem jobItem, SyncJob job)
|
||||
public ISyncProvider GetSyncProvider(SyncJobItem jobItem)
|
||||
{
|
||||
foreach (var provider in _providers)
|
||||
{
|
||||
|
@ -1323,9 +1323,9 @@ namespace MediaBrowser.Server.Implementations.Sync
|
|||
return list;
|
||||
}
|
||||
|
||||
protected internal void OnConversionComplete(SyncJobItem item, SyncJob job)
|
||||
protected internal void OnConversionComplete(SyncJobItem item)
|
||||
{
|
||||
var syncProvider = GetSyncProvider(item, job);
|
||||
var syncProvider = GetSyncProvider(item);
|
||||
if (syncProvider is AppSyncProvider)
|
||||
{
|
||||
return;
|
||||
|
|
|
@ -104,7 +104,7 @@ namespace MediaBrowser.Server.Implementations.Sync
|
|||
|
||||
// _updateJobCommand
|
||||
_updateJobCommand = _connection.CreateCommand();
|
||||
_updateJobCommand.CommandText = "update SyncJobs set TargetId=@TargetId,Name=@Name,Profile=@Profile,Quality=@Quality,Bitrate=@Bitrate,Status=@Status,Progress=@Progress,UserId=@UserId,ItemIds=@ItemIds,Category=@Category,ParentId=@ParentId,UnwatchedOnly=@UnwatchedOnly,ItemLimit=@ItemLimit,SyncNewContent=@SyncNewContent,DateCreated=@DateCreated,DateLastModified=@DateLastModified,ItemCount=@ItemCount where Id=@ID";
|
||||
_updateJobCommand.CommandText = "update SyncJobs set TargetId=@TargetId,Name=@Name,Profile=@Profile,Quality=@Quality,Bitrate=@Bitrate,Status=@Status,Progress=@Progress,UserId=@UserId,ItemIds=@ItemIds,Category=@Category,ParentId=@ParentId,UnwatchedOnly=@UnwatchedOnly,ItemLimit=@ItemLimit,SyncNewContent=@SyncNewContent,DateCreated=@DateCreated,DateLastModified=@DateLastModified,ItemCount=@ItemCount where Id=@Id";
|
||||
|
||||
_updateJobCommand.Parameters.Add(_updateJobCommand, "@Id");
|
||||
_updateJobCommand.Parameters.Add(_updateJobCommand, "@TargetId");
|
||||
|
|
Loading…
Reference in New Issue
Block a user