commit
e52a94e883
|
@ -102,6 +102,8 @@ namespace MediaBrowser.Model.Sync
|
|||
/// <value>The index of the job item.</value>
|
||||
public int JobItemIndex { get; set; }
|
||||
|
||||
public long ItemDateModifiedTicks { get; set; }
|
||||
|
||||
public SyncJobItem()
|
||||
{
|
||||
AdditionalFiles = new List<ItemFileInfo>();
|
||||
|
|
|
@ -149,6 +149,11 @@ namespace MediaBrowser.Server.Implementations.Sync
|
|||
{
|
||||
var job = _syncRepo.GetJob(id);
|
||||
|
||||
if (job == null)
|
||||
{
|
||||
return Task.FromResult(true);
|
||||
}
|
||||
|
||||
var result = _syncManager.GetJobItems(new SyncJobItemQuery
|
||||
{
|
||||
JobId = job.Id,
|
||||
|
@ -632,6 +637,7 @@ namespace MediaBrowser.Server.Implementations.Sync
|
|||
|
||||
}, innerProgress, cancellationToken);
|
||||
|
||||
jobItem.ItemDateModifiedTicks = item.DateModified.Ticks;
|
||||
_syncManager.OnConversionComplete(jobItem);
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
|
@ -668,6 +674,7 @@ namespace MediaBrowser.Server.Implementations.Sync
|
|||
throw new InvalidOperationException(string.Format("Cannot direct stream {0} protocol", mediaSource.Protocol));
|
||||
}
|
||||
|
||||
jobItem.ItemDateModifiedTicks = item.DateModified.Ticks;
|
||||
jobItem.MediaSource = mediaSource;
|
||||
}
|
||||
|
||||
|
@ -819,6 +826,7 @@ namespace MediaBrowser.Server.Implementations.Sync
|
|||
|
||||
}, innerProgress, cancellationToken);
|
||||
|
||||
jobItem.ItemDateModifiedTicks = item.DateModified.Ticks;
|
||||
_syncManager.OnConversionComplete(jobItem);
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
|
@ -855,6 +863,7 @@ namespace MediaBrowser.Server.Implementations.Sync
|
|||
throw new InvalidOperationException(string.Format("Cannot direct stream {0} protocol", mediaSource.Protocol));
|
||||
}
|
||||
|
||||
jobItem.ItemDateModifiedTicks = item.DateModified.Ticks;
|
||||
jobItem.MediaSource = mediaSource;
|
||||
}
|
||||
|
||||
|
@ -871,6 +880,7 @@ namespace MediaBrowser.Server.Implementations.Sync
|
|||
|
||||
jobItem.Progress = 50;
|
||||
jobItem.Status = SyncJobItemStatus.ReadyToTransfer;
|
||||
jobItem.ItemDateModifiedTicks = item.DateModified.Ticks;
|
||||
await _syncManager.UpdateSyncJobItemInternal(jobItem).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
|
@ -880,6 +890,7 @@ namespace MediaBrowser.Server.Implementations.Sync
|
|||
|
||||
jobItem.Progress = 50;
|
||||
jobItem.Status = SyncJobItemStatus.ReadyToTransfer;
|
||||
jobItem.ItemDateModifiedTicks = item.DateModified.Ticks;
|
||||
await _syncManager.UpdateSyncJobItemInternal(jobItem).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
|
|
|
@ -775,6 +775,13 @@ namespace MediaBrowser.Server.Implementations.Sync
|
|||
removeFromDevice = true;
|
||||
}
|
||||
}
|
||||
else if (libraryItem != null && libraryItem.DateModified.Ticks != jobItem.ItemDateModifiedTicks && jobItem.ItemDateModifiedTicks > 0)
|
||||
{
|
||||
_logger.Info("Setting status to Queued for {0} because the media has been modified since the original sync.", jobItem.ItemId);
|
||||
jobItem.Status = SyncJobItemStatus.Queued;
|
||||
jobItem.Progress = 0;
|
||||
requiresSaving = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -881,6 +888,13 @@ namespace MediaBrowser.Server.Implementations.Sync
|
|||
removeFromDevice = true;
|
||||
}
|
||||
}
|
||||
else if (libraryItem != null && libraryItem.DateModified.Ticks != jobItem.ItemDateModifiedTicks && jobItem.ItemDateModifiedTicks > 0)
|
||||
{
|
||||
_logger.Info("Setting status to Queued for {0} because the media has been modified since the original sync.", jobItem.ItemId);
|
||||
jobItem.Status = SyncJobItemStatus.Queued;
|
||||
jobItem.Progress = 0;
|
||||
requiresSaving = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1117,7 +1131,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;
|
||||
|
|
|
@ -50,7 +50,7 @@ namespace MediaBrowser.Server.Implementations.Sync
|
|||
"create table if not exists SyncJobs (Id GUID PRIMARY KEY, TargetId TEXT NOT NULL, Name TEXT NOT NULL, Profile TEXT, Quality TEXT, Bitrate INT, Status TEXT NOT NULL, Progress FLOAT, UserId TEXT NOT NULL, ItemIds TEXT NOT NULL, Category TEXT, ParentId TEXT, UnwatchedOnly BIT, ItemLimit INT, SyncNewContent BIT, DateCreated DateTime, DateLastModified DateTime, ItemCount int)",
|
||||
"create index if not exists idx_SyncJobs on SyncJobs(Id)",
|
||||
|
||||
"create table if not exists SyncJobItems (Id GUID PRIMARY KEY, ItemId TEXT, ItemName TEXT, MediaSourceId TEXT, JobId TEXT, TemporaryPath TEXT, OutputPath TEXT, Status TEXT, TargetId TEXT, DateCreated DateTime, Progress FLOAT, AdditionalFiles TEXT, MediaSource TEXT, IsMarkedForRemoval BIT, JobItemIndex INT)",
|
||||
"create table if not exists SyncJobItems (Id GUID PRIMARY KEY, ItemId TEXT, ItemName TEXT, MediaSourceId TEXT, JobId TEXT, TemporaryPath TEXT, OutputPath TEXT, Status TEXT, TargetId TEXT, DateCreated DateTime, Progress FLOAT, AdditionalFiles TEXT, MediaSource TEXT, IsMarkedForRemoval BIT, JobItemIndex INT, ItemDateModifiedTicks BIGINT)",
|
||||
"create index if not exists idx_SyncJobItems on SyncJobs(Id)",
|
||||
|
||||
//pragmas
|
||||
|
@ -63,6 +63,7 @@ namespace MediaBrowser.Server.Implementations.Sync
|
|||
|
||||
_connection.AddColumn(Logger, "SyncJobs", "Profile", "TEXT");
|
||||
_connection.AddColumn(Logger, "SyncJobs", "Bitrate", "INT");
|
||||
_connection.AddColumn(Logger, "SyncJobItems", "ItemDateModifiedTicks", "BIGINT");
|
||||
|
||||
PrepareStatements();
|
||||
}
|
||||
|
@ -127,7 +128,7 @@ namespace MediaBrowser.Server.Implementations.Sync
|
|||
|
||||
// _insertJobItemCommand
|
||||
_insertJobItemCommand = _connection.CreateCommand();
|
||||
_insertJobItemCommand.CommandText = "insert into SyncJobItems (Id, ItemId, ItemName, MediaSourceId, JobId, TemporaryPath, OutputPath, Status, TargetId, DateCreated, Progress, AdditionalFiles, MediaSource, IsMarkedForRemoval, JobItemIndex) values (@Id, @ItemId, @ItemName, @MediaSourceId, @JobId, @TemporaryPath, @OutputPath, @Status, @TargetId, @DateCreated, @Progress, @AdditionalFiles, @MediaSource, @IsMarkedForRemoval, @JobItemIndex)";
|
||||
_insertJobItemCommand.CommandText = "insert into SyncJobItems (Id, ItemId, ItemName, MediaSourceId, JobId, TemporaryPath, OutputPath, Status, TargetId, DateCreated, Progress, AdditionalFiles, MediaSource, IsMarkedForRemoval, JobItemIndex, ItemDateModifiedTicks) values (@Id, @ItemId, @ItemName, @MediaSourceId, @JobId, @TemporaryPath, @OutputPath, @Status, @TargetId, @DateCreated, @Progress, @AdditionalFiles, @MediaSource, @IsMarkedForRemoval, @JobItemIndex, @ItemDateModifiedTicks)";
|
||||
|
||||
_insertJobItemCommand.Parameters.Add(_insertJobItemCommand, "@Id");
|
||||
_insertJobItemCommand.Parameters.Add(_insertJobItemCommand, "@ItemId");
|
||||
|
@ -144,10 +145,11 @@ namespace MediaBrowser.Server.Implementations.Sync
|
|||
_insertJobItemCommand.Parameters.Add(_insertJobItemCommand, "@MediaSource");
|
||||
_insertJobItemCommand.Parameters.Add(_insertJobItemCommand, "@IsMarkedForRemoval");
|
||||
_insertJobItemCommand.Parameters.Add(_insertJobItemCommand, "@JobItemIndex");
|
||||
_insertJobItemCommand.Parameters.Add(_insertJobItemCommand, "@ItemDateModifiedTicks");
|
||||
|
||||
// _updateJobItemCommand
|
||||
_updateJobItemCommand = _connection.CreateCommand();
|
||||
_updateJobItemCommand.CommandText = "update SyncJobItems set ItemId=@ItemId,ItemName=@ItemName,MediaSourceId=@MediaSourceId,JobId=@JobId,TemporaryPath=@TemporaryPath,OutputPath=@OutputPath,Status=@Status,TargetId=@TargetId,DateCreated=@DateCreated,Progress=@Progress,AdditionalFiles=@AdditionalFiles,MediaSource=@MediaSource,IsMarkedForRemoval=@IsMarkedForRemoval,JobItemIndex=@JobItemIndex where Id=@Id";
|
||||
_updateJobItemCommand.CommandText = "update SyncJobItems set ItemId=@ItemId,ItemName=@ItemName,MediaSourceId=@MediaSourceId,JobId=@JobId,TemporaryPath=@TemporaryPath,OutputPath=@OutputPath,Status=@Status,TargetId=@TargetId,DateCreated=@DateCreated,Progress=@Progress,AdditionalFiles=@AdditionalFiles,MediaSource=@MediaSource,IsMarkedForRemoval=@IsMarkedForRemoval,JobItemIndex=@JobItemIndex,ItemDateModifiedTicks=@ItemDateModifiedTicks where Id=@Id";
|
||||
|
||||
_updateJobItemCommand.Parameters.Add(_updateJobItemCommand, "@Id");
|
||||
_updateJobItemCommand.Parameters.Add(_updateJobItemCommand, "@ItemId");
|
||||
|
@ -164,10 +166,11 @@ namespace MediaBrowser.Server.Implementations.Sync
|
|||
_updateJobItemCommand.Parameters.Add(_updateJobItemCommand, "@MediaSource");
|
||||
_updateJobItemCommand.Parameters.Add(_updateJobItemCommand, "@IsMarkedForRemoval");
|
||||
_updateJobItemCommand.Parameters.Add(_updateJobItemCommand, "@JobItemIndex");
|
||||
_updateJobItemCommand.Parameters.Add(_updateJobItemCommand, "@ItemDateModifiedTicks");
|
||||
}
|
||||
|
||||
private const string BaseJobSelectText = "select Id, TargetId, Name, Profile, Quality, Bitrate, Status, Progress, UserId, ItemIds, Category, ParentId, UnwatchedOnly, ItemLimit, SyncNewContent, DateCreated, DateLastModified, ItemCount from SyncJobs";
|
||||
private const string BaseJobItemSelectText = "select Id, ItemId, ItemName, MediaSourceId, JobId, TemporaryPath, OutputPath, Status, TargetId, DateCreated, Progress, AdditionalFiles, MediaSource, IsMarkedForRemoval, JobItemIndex from SyncJobItems";
|
||||
private const string BaseJobItemSelectText = "select Id, ItemId, ItemName, MediaSourceId, JobId, TemporaryPath, OutputPath, Status, TargetId, DateCreated, Progress, AdditionalFiles, MediaSource, IsMarkedForRemoval, JobItemIndex, ItemDateModifiedTicks from SyncJobItems";
|
||||
|
||||
public SyncJob GetJob(string id)
|
||||
{
|
||||
|
@ -678,6 +681,7 @@ namespace MediaBrowser.Server.Implementations.Sync
|
|||
cmd.GetParameter(index++).Value = jobItem.MediaSource == null ? null : _json.SerializeToString(jobItem.MediaSource);
|
||||
cmd.GetParameter(index++).Value = jobItem.IsMarkedForRemoval;
|
||||
cmd.GetParameter(index++).Value = jobItem.JobItemIndex;
|
||||
cmd.GetParameter(index++).Value = jobItem.ItemDateModifiedTicks;
|
||||
|
||||
cmd.Transaction = transaction;
|
||||
|
||||
|
@ -782,6 +786,11 @@ namespace MediaBrowser.Server.Implementations.Sync
|
|||
info.IsMarkedForRemoval = reader.GetBoolean(13);
|
||||
info.JobItemIndex = reader.GetInt32(14);
|
||||
|
||||
if (!reader.IsDBNull(15))
|
||||
{
|
||||
info.ItemDateModifiedTicks = reader.GetInt64(15);
|
||||
}
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user