add mark for removal options

This commit is contained in:
Luke Pulverenti 2015-01-20 23:56:00 -05:00
parent f636c10e24
commit f5b7e1dba4
6 changed files with 119 additions and 2 deletions

View File

@ -44,6 +44,20 @@ namespace MediaBrowser.Api.Sync
public string Id { get; set; }
}
[Route("/Sync/JobItems/{Id}/MarkForRemoval", "POST", Summary = "Marks a job item for removal")]
public class MarkJobItemForRemoval : IReturnVoid
{
[ApiMember(Name = "Id", Description = "Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "POST")]
public string Id { get; set; }
}
[Route("/Sync/JobItems/{Id}/UnmarkForRemoval", "POST", Summary = "Unmarks a job item for removal")]
public class UnmarkJobItemForRemoval : IReturnVoid
{
[ApiMember(Name = "Id", Description = "Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "POST")]
public string Id { get; set; }
}
[Route("/Sync/JobItems/{Id}", "DELETE", Summary = "Cancels a sync job item")]
public class CancelSyncJobItem : IReturnVoid
{
@ -299,5 +313,19 @@ namespace MediaBrowser.Api.Sync
Task.WaitAll(task);
}
public void Post(MarkJobItemForRemoval request)
{
var task = _syncManager.MarkJobItemForRemoval(request.Id);
Task.WaitAll(task);
}
public void Post(UnmarkJobItemForRemoval request)
{
var task = _syncManager.UnmarkJobItemForRemoval(request.Id);
Task.WaitAll(task);
}
}
}

View File

@ -128,5 +128,19 @@ namespace MediaBrowser.Controller.Sync
/// <param name="request">The request.</param>
/// <returns>Task&lt;SyncDataResponse&gt;.</returns>
Task<SyncDataResponse> SyncData(SyncDataRequest request);
/// <summary>
/// Marks the job item for removal.
/// </summary>
/// <param name="id">The identifier.</param>
/// <returns>Task.</returns>
Task MarkJobItemForRemoval(string id);
/// <summary>
/// Unmarks the job item for removal.
/// </summary>
/// <param name="id">The identifier.</param>
/// <returns>Task.</returns>
Task UnmarkJobItemForRemoval(string id);
}
}

View File

@ -1449,12 +1449,41 @@ namespace MediaBrowser.Model.ApiClient
/// <param name="request">The request.</param>
/// <returns>Task&lt;SyncDataResponse&gt;.</returns>
Task<SyncDataResponse> SyncData(SyncDataRequest request);
/// <summary>
/// Gets the synchronize job item file URL.
/// </summary>
/// <param name="id">The identifier.</param>
/// <returns>System.String.</returns>
string GetSyncJobItemFileUrl(string id);
/// <summary>
/// Marks the synchronize job item for removal.
/// </summary>
/// <param name="id">The identifier.</param>
/// <returns>Task.</returns>
Task MarkSyncJobItemForRemoval(string id);
/// <summary>
/// Unmarks the synchronize job item for removal.
/// </summary>
/// <param name="id">The identifier.</param>
/// <returns>Task.</returns>
Task UnmarkSyncJobItemForRemoval(string id);
/// <summary>
/// Queues the failed synchronize job item for retry.
/// </summary>
/// <param name="id">The identifier.</param>
/// <returns>Task.</returns>
Task QueueFailedSyncJobItemForRetry(string id);
/// <summary>
/// Cancels the synchronize job item.
/// </summary>
/// <param name="id">The identifier.</param>
/// <returns>Task.</returns>
Task CancelSyncJobItem(string id);
/// <summary>
/// Enables the cancelled synchronize job item.
/// </summary>
/// <param name="id">The identifier.</param>
/// <returns>Task.</returns>
Task EnableCancelledSyncJobItem(string id);
}
}

View File

@ -86,8 +86,15 @@ namespace MediaBrowser.Model.Sync
/// </summary>
/// <value>The temporary path.</value>
public string TemporaryPath { get; set; }
/// <summary>
/// Gets or sets the additional files.
/// </summary>
/// <value>The additional files.</value>
public List<ItemFileInfo> AdditionalFiles { get; set; }
/// <summary>
/// Gets or sets a value indicating whether this instance is marked for removal.
/// </summary>
/// <value><c>true</c> if this instance is marked for removal; otherwise, <c>false</c>.</value>
public bool IsMarkedForRemoval { get; set; }
public SyncJobItem()

View File

@ -59,6 +59,7 @@
"ButtonCancelItem": "Cancel item",
"ButtonQueueForRetry": "Queue for retry",
"ButtonReenable": "Re-enable",
"SyncJobItemStatusSyncedMarkForRemoval": "Marked for removal",
"LabelAbortedByServerShutdown": "(Aborted by server shutdown)",
"LabelScheduledTaskLastRan": "Last ran {0}, taking {1}.",
"HeaderDeleteTaskTrigger": "Delete Task Trigger",
@ -70,6 +71,8 @@
"LabelFree": "Free",
"HeaderSelectAudio": "Select Audio",
"HeaderSelectSubtitles": "Select Subtitles",
"ButtonMarkForRemoval": "Mark for removal from device",
"ButtonUnmarkForRemoval": "Unmark for removal from device",
"LabelDefaultStream": "(Default)",
"LabelForcedStream": "(Forced)",
"LabelDefaultForcedStream": "(Default/Forced)",

View File

@ -684,5 +684,41 @@ namespace MediaBrowser.Server.Implementations.Sync
await processor.UpdateJobStatus(jobItem.JobId).ConfigureAwait(false);
}
public async Task MarkJobItemForRemoval(string id)
{
var jobItem = _repo.GetJobItem(id);
if (jobItem.Status != SyncJobItemStatus.Synced)
{
throw new ArgumentException("Operation is not valid for this job item");
}
jobItem.IsMarkedForRemoval = true;
await _repo.Update(jobItem).ConfigureAwait(false);
var processor = GetSyncJobProcessor();
await processor.UpdateJobStatus(jobItem.JobId).ConfigureAwait(false);
}
public async Task UnmarkJobItemForRemoval(string id)
{
var jobItem = _repo.GetJobItem(id);
if (jobItem.Status != SyncJobItemStatus.Synced)
{
throw new ArgumentException("Operation is not valid for this job item");
}
jobItem.IsMarkedForRemoval = false;
await _repo.Update(jobItem).ConfigureAwait(false);
var processor = GetSyncJobProcessor();
await processor.UpdateJobStatus(jobItem.JobId).ConfigureAwait(false);
}
}
}