@ -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 , job Item, enableConversion , innerProgress , cancellationToken ) . ConfigureAwait ( false ) ;
await ProcessJobItem ( job Item, 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 , SyncJob Item jobItem , bool enableConversion , IProgress < double > progress , CancellationToken cancellationToken )
private async Task ProcessJobItem ( SyncJob Item 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 = job Item . 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 ( job Item. 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 ( job Item. 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 ( job Item. 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 ( job Item. JobId ) . ConfigureAwait ( false ) ;
}
} ) ;
@ -828,7 +819,7 @@ namespace MediaBrowser.Server.Implementations.Sync
} , innerProgress , cancellationToken ) ;
_syncManager . OnConversionComplete ( jobItem , job );
_syncManager . OnConversionComplete ( jobItem );
}
catch ( OperationCanceledException )
{