sync updates
This commit is contained in:
parent
e035e032d0
commit
7f537ad149
|
@ -430,7 +430,14 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||||
{
|
{
|
||||||
var tuple = GetProvider(id);
|
var tuple = GetProvider(id);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
await tuple.Item1.CloseMediaSource(tuple.Item2, cancellationToken).ConfigureAwait(false);
|
await tuple.Item1.CloseMediaSource(tuple.Item2, cancellationToken).ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
catch (NotImplementedException)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
LiveStreamInfo removed;
|
LiveStreamInfo removed;
|
||||||
if (_openStreams.TryRemove(id, out removed))
|
if (_openStreams.TryRemove(id, out removed))
|
||||||
|
|
|
@ -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)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -676,14 +676,16 @@ namespace MediaBrowser.Server.Implementations.Sync
|
||||||
|
|
||||||
syncedItem.Item.MediaSources = new List<MediaSourceInfo>();
|
syncedItem.Item.MediaSources = new List<MediaSourceInfo>();
|
||||||
|
|
||||||
// This will be null for items that are not audio/video
|
|
||||||
if (mediaSource == null)
|
|
||||||
{
|
|
||||||
syncedItem.OriginalFileName = Path.GetFileName(libraryItem.Path);
|
syncedItem.OriginalFileName = Path.GetFileName(libraryItem.Path);
|
||||||
}
|
|
||||||
else
|
if (string.IsNullOrWhiteSpace(syncedItem.OriginalFileName))
|
||||||
{
|
{
|
||||||
syncedItem.OriginalFileName = Path.GetFileName(mediaSource.Path);
|
syncedItem.OriginalFileName = Path.GetFileName(mediaSource.Path);
|
||||||
|
}
|
||||||
|
|
||||||
|
// This will be null for items that are not audio/video
|
||||||
|
if (mediaSource != null)
|
||||||
|
{
|
||||||
syncedItem.Item.MediaSources.Add(mediaSource);
|
syncedItem.Item.MediaSources.Add(mediaSource);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user