sync updates

pull/702/head
Luke Pulverenti 10 years ago
parent e035e032d0
commit 7f537ad149

@ -430,7 +430,14 @@ namespace MediaBrowser.Server.Implementations.Library
{
var tuple = GetProvider(id);
await tuple.Item1.CloseMediaSource(tuple.Item2, cancellationToken).ConfigureAwait(false);
try
{
await tuple.Item1.CloseMediaSource(tuple.Item2, cancellationToken).ConfigureAwait(false);
}
catch (NotImplementedException)
{
}
LiveStreamInfo removed;
if (_openStreams.TryRemove(id, out removed))

@ -40,6 +40,7 @@ namespace MediaBrowser.Server.Implementations.Sync
CancellationToken cancellationToken)
{
var serverId = _appHost.SystemId;
var serverName = _appHost.FriendlyName;
await SyncData(provider, dataProvider, serverId, target, cancellationToken).ConfigureAwait(false);
progress.Report(3);
@ -51,7 +52,7 @@ namespace MediaBrowser.Server.Implementations.Sync
totalProgress += 1;
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
await SyncData(provider, dataProvider, serverId, target, cancellationToken).ConfigureAwait(false);
@ -93,6 +94,7 @@ namespace MediaBrowser.Server.Implementations.Sync
ISyncDataProvider dataProvider,
SyncTarget target,
string serverId,
string serverName,
IProgress<double> progress,
CancellationToken cancellationToken)
{
@ -119,7 +121,7 @@ namespace MediaBrowser.Server.Implementations.Sync
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++;
startingPercent = numComplete;
@ -133,6 +135,7 @@ namespace MediaBrowser.Server.Implementations.Sync
ISyncDataProvider dataProvider,
SyncTarget target,
string serverId,
string serverName,
SyncedItem jobItem,
IProgress<double> progress,
CancellationToken cancellationToken)
@ -140,7 +143,7 @@ namespace MediaBrowser.Server.Implementations.Sync
var libraryItem = jobItem.Item;
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);
@ -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));
var localPath = provider.GetFullPath(path, target);
@ -361,11 +364,11 @@ namespace MediaBrowser.Server.Implementations.Sync
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>
{
serverId,
serverName,
GetSyncJobFolderName(syncedItem, provider)
};

@ -676,14 +676,16 @@ namespace MediaBrowser.Server.Implementations.Sync
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);
if (string.IsNullOrWhiteSpace(syncedItem.OriginalFileName))
{
syncedItem.OriginalFileName = Path.GetFileName(libraryItem.Path);
syncedItem.OriginalFileName = Path.GetFileName(mediaSource.Path);
}
else
// This will be null for items that are not audio/video
if (mediaSource != null)
{
syncedItem.OriginalFileName = Path.GetFileName(mediaSource.Path);
syncedItem.Item.MediaSources.Add(mediaSource);
}

Loading…
Cancel
Save