|
|
@ -40,6 +40,7 @@ namespace MediaBrowser.Server.Implementations.Sync
|
|
|
|
CancellationToken cancellationToken)
|
|
|
|
CancellationToken cancellationToken)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var serverId = _appHost.SystemId;
|
|
|
|
var serverId = _appHost.SystemId;
|
|
|
|
|
|
|
|
var serverName = _appHost.FriendlyName;
|
|
|
|
|
|
|
|
|
|
|
|
await SyncData(provider, dataProvider, serverId, target, cancellationToken).ConfigureAwait(false);
|
|
|
|
await SyncData(provider, dataProvider, serverId, target, cancellationToken).ConfigureAwait(false);
|
|
|
|
progress.Report(3);
|
|
|
|
progress.Report(3);
|
|
|
@ -51,7 +52,7 @@ namespace MediaBrowser.Server.Implementations.Sync
|
|
|
|
totalProgress += 1;
|
|
|
|
totalProgress += 1;
|
|
|
|
progress.Report(totalProgress);
|
|
|
|
progress.Report(totalProgress);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
await GetNewMedia(provider, dataProvider, target, serverId, innerProgress, cancellationToken);
|
|
|
|
await GetNewMedia(provider, dataProvider, target, serverId, serverName, innerProgress, cancellationToken);
|
|
|
|
|
|
|
|
|
|
|
|
// Do the data sync twice so the server knows what was removed from the device
|
|
|
|
// Do the data sync twice so the server knows what was removed from the device
|
|
|
|
await SyncData(provider, dataProvider, serverId, target, cancellationToken).ConfigureAwait(false);
|
|
|
|
await SyncData(provider, dataProvider, serverId, target, cancellationToken).ConfigureAwait(false);
|
|
|
@ -93,6 +94,7 @@ namespace MediaBrowser.Server.Implementations.Sync
|
|
|
|
ISyncDataProvider dataProvider,
|
|
|
|
ISyncDataProvider dataProvider,
|
|
|
|
SyncTarget target,
|
|
|
|
SyncTarget target,
|
|
|
|
string serverId,
|
|
|
|
string serverId,
|
|
|
|
|
|
|
|
string serverName,
|
|
|
|
IProgress<double> progress,
|
|
|
|
IProgress<double> progress,
|
|
|
|
CancellationToken cancellationToken)
|
|
|
|
CancellationToken cancellationToken)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -119,7 +121,7 @@ namespace MediaBrowser.Server.Implementations.Sync
|
|
|
|
progress.Report(totalProgress);
|
|
|
|
progress.Report(totalProgress);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
await GetItem(provider, dataProvider, target, serverId, jobItem, innerProgress, cancellationToken).ConfigureAwait(false);
|
|
|
|
await GetItem(provider, dataProvider, target, serverId, serverName, jobItem, innerProgress, cancellationToken).ConfigureAwait(false);
|
|
|
|
|
|
|
|
|
|
|
|
numComplete++;
|
|
|
|
numComplete++;
|
|
|
|
startingPercent = numComplete;
|
|
|
|
startingPercent = numComplete;
|
|
|
@ -133,6 +135,7 @@ namespace MediaBrowser.Server.Implementations.Sync
|
|
|
|
ISyncDataProvider dataProvider,
|
|
|
|
ISyncDataProvider dataProvider,
|
|
|
|
SyncTarget target,
|
|
|
|
SyncTarget target,
|
|
|
|
string serverId,
|
|
|
|
string serverId,
|
|
|
|
|
|
|
|
string serverName,
|
|
|
|
SyncedItem jobItem,
|
|
|
|
SyncedItem jobItem,
|
|
|
|
IProgress<double> progress,
|
|
|
|
IProgress<double> progress,
|
|
|
|
CancellationToken cancellationToken)
|
|
|
|
CancellationToken cancellationToken)
|
|
|
@ -140,7 +143,7 @@ namespace MediaBrowser.Server.Implementations.Sync
|
|
|
|
var libraryItem = jobItem.Item;
|
|
|
|
var libraryItem = jobItem.Item;
|
|
|
|
var internalSyncJobItem = _syncManager.GetJobItem(jobItem.SyncJobItemId);
|
|
|
|
var internalSyncJobItem = _syncManager.GetJobItem(jobItem.SyncJobItemId);
|
|
|
|
|
|
|
|
|
|
|
|
var localItem = CreateLocalItem(provider, jobItem, target, libraryItem, serverId, jobItem.OriginalFileName);
|
|
|
|
var localItem = CreateLocalItem(provider, jobItem, target, libraryItem, serverId, serverName, jobItem.OriginalFileName);
|
|
|
|
|
|
|
|
|
|
|
|
await _syncManager.ReportSyncJobItemTransferBeginning(internalSyncJobItem.Id);
|
|
|
|
await _syncManager.ReportSyncJobItemTransferBeginning(internalSyncJobItem.Id);
|
|
|
|
|
|
|
|
|
|
|
@ -326,9 +329,9 @@ namespace MediaBrowser.Server.Implementations.Sync
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public LocalItem CreateLocalItem(IServerSyncProvider provider, SyncedItem syncedItem, SyncTarget target, BaseItemDto libraryItem, string serverId, string originalFileName)
|
|
|
|
public LocalItem CreateLocalItem(IServerSyncProvider provider, SyncedItem syncedItem, SyncTarget target, BaseItemDto libraryItem, string serverId, string serverName, string originalFileName)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var path = GetDirectoryPath(provider, syncedItem, libraryItem, serverId);
|
|
|
|
var path = GetDirectoryPath(provider, syncedItem, libraryItem, serverId, serverName);
|
|
|
|
path.Add(GetLocalFileName(provider, libraryItem, originalFileName));
|
|
|
|
path.Add(GetLocalFileName(provider, libraryItem, originalFileName));
|
|
|
|
|
|
|
|
|
|
|
|
var localPath = provider.GetFullPath(path, target);
|
|
|
|
var localPath = provider.GetFullPath(path, target);
|
|
|
@ -361,11 +364,11 @@ namespace MediaBrowser.Server.Implementations.Sync
|
|
|
|
return name;
|
|
|
|
return name;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private List<string> GetDirectoryPath(IServerSyncProvider provider, SyncedItem syncedItem, BaseItemDto item, string serverId)
|
|
|
|
private List<string> GetDirectoryPath(IServerSyncProvider provider, SyncedItem syncedItem, BaseItemDto item, string serverId, string serverName)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var parts = new List<string>
|
|
|
|
var parts = new List<string>
|
|
|
|
{
|
|
|
|
{
|
|
|
|
serverId,
|
|
|
|
serverName,
|
|
|
|
GetSyncJobFolderName(syncedItem, provider)
|
|
|
|
GetSyncJobFolderName(syncedItem, provider)
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|