cloud sync progress

This commit is contained in:
Luke Pulverenti 2015-02-22 14:05:38 -05:00
parent 20ceca1479
commit 084df0a20e
4 changed files with 39 additions and 11 deletions

View file

@ -1,5 +1,7 @@
using MediaBrowser.Model.Sync;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
namespace MediaBrowser.Controller.Sync
{
@ -17,5 +19,17 @@ namespace MediaBrowser.Controller.Sync
/// <param name="userId">The user identifier.</param>
/// <returns>IEnumerable&lt;SyncTarget&gt;.</returns>
IEnumerable<SyncTarget> GetSyncTargets(string userId);
/// <summary>
/// Transfers the item file.
/// </summary>
/// <param name="serverId">The server identifier.</param>
/// <param name="itemId">The item identifier.</param>
/// <param name="inputFile">The input file.</param>
/// <param name="pathParts">The path parts.</param>
/// <param name="target">The target.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Task.</returns>
Task TransferItemFile(string serverId, string itemId, string inputFile, string[] pathParts, SyncTarget target, CancellationToken cancellationToken);
}
}

View file

@ -31,12 +31,11 @@ namespace MediaBrowser.Controller.Sync
/// </summary>
/// <param name="serverId">The server identifier.</param>
/// <param name="itemId">The item identifier.</param>
/// <param name="inputFile">The input file.</param>
/// <param name="pathParts">The path parts.</param>
/// <param name="name">The name.</param>
/// <param name="fileType">Type of the file.</param>
/// <param name="target">The target.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Task.</returns>
Task TransferItemFile(string serverId, string itemId, string[] pathParts, string name, ItemFileType fileType, SyncTarget target, CancellationToken cancellationToken);
Task TransferItemFile(string serverId, string itemId, string inputFile, string[] pathParts, SyncTarget target, CancellationToken cancellationToken);
}
}

View file

@ -34,6 +34,11 @@ namespace MediaBrowser.Server.Implementations.Sync
get { return "Cloud Sync"; }
}
private ICloudSyncProvider GetProvider(SyncTarget target)
{
return null;
}
public Task<List<string>> GetServerItemIds(string serverId, SyncTarget target, CancellationToken cancellationToken)
{
throw new NotImplementedException();
@ -44,9 +49,11 @@ namespace MediaBrowser.Server.Implementations.Sync
throw new NotImplementedException();
}
public Task TransferItemFile(string serverId, string itemId, string[] pathParts, string name, ItemFileType fileType, SyncTarget target, CancellationToken cancellationToken)
public Task TransferItemFile(string serverId, string itemId, string inputFile, string[] pathParts, SyncTarget target, CancellationToken cancellationToken)
{
throw new NotImplementedException();
var provider = GetProvider(target);
return provider.TransferItemFile(serverId, itemId, inputFile, pathParts, target, cancellationToken);
}
}
}

View file

@ -1,6 +1,7 @@
using MediaBrowser.Common.Progress;
using MediaBrowser.Controller;
using MediaBrowser.Controller.Sync;
using MediaBrowser.Model.Dto;
using MediaBrowser.Model.Logging;
using MediaBrowser.Model.Sync;
using System;
@ -29,10 +30,6 @@ namespace MediaBrowser.Server.Implementations.Sync
{
var serverId = _appHost.SystemId;
await SyncData(provider, serverId, target, cancellationToken).ConfigureAwait(false);
progress.Report(2);
// Do the data sync twice so the server knows what was removed from the device
await SyncData(provider, serverId, target, cancellationToken).ConfigureAwait(false);
progress.Report(3);
@ -44,6 +41,10 @@ namespace MediaBrowser.Server.Implementations.Sync
progress.Report(totalProgress);
});
await GetNewMedia(provider, target, serverId, innerProgress, cancellationToken);
// Do the data sync twice so the server knows what was removed from the device
await SyncData(provider, serverId, target, cancellationToken).ConfigureAwait(false);
progress.Report(100);
}
@ -135,8 +136,10 @@ namespace MediaBrowser.Server.Implementations.Sync
try
{
//await provider.TransferItemFile(serverId, libraryItem.Id, internalSyncJobItem.OutputPath, target, cancellationToken)
// .ConfigureAwait(false);
string[] pathParts = GetPathParts(serverId, libraryItem);
await provider.TransferItemFile(serverId, libraryItem.Id, internalSyncJobItem.OutputPath, pathParts, target, cancellationToken)
.ConfigureAwait(false);
progress.Report(92);
@ -170,5 +173,10 @@ namespace MediaBrowser.Server.Implementations.Sync
{
return provider.DeleteItem(serverId, itemId, target, cancellationToken);
}
private string[] GetPathParts(string serverId, BaseItemDto item)
{
return null;
}
}
}