update server sync

This commit is contained in:
Luke Pulverenti
2015-03-13 01:29:39 -04:00
parent b7b28ffd31
commit 4309455c37
10 changed files with 45 additions and 32 deletions

View File

@@ -152,7 +152,18 @@ namespace MediaBrowser.Server.Implementations.Sync
try
{
await SendFile(provider, internalSyncJobItem.OutputPath, localItem, target, cancellationToken).ConfigureAwait(false);
var sendFileResult = await SendFile(provider, internalSyncJobItem.OutputPath, localItem, target, cancellationToken).ConfigureAwait(false);
if (localItem.Item.MediaSources != null)
{
var mediaSource = localItem.Item.MediaSources.FirstOrDefault();
if (mediaSource != null)
{
mediaSource.Path = sendFileResult.Path;
mediaSource.Protocol = sendFileResult.Protocol;
mediaSource.SupportsTranscoding = false;
}
}
// Create db record
await dataProvider.AddOrUpdate(target, localItem).ConfigureAwait(false);
@@ -203,11 +214,11 @@ namespace MediaBrowser.Server.Implementations.Sync
}
}
private async Task SendFile(IServerSyncProvider provider, string inputPath, LocalItem item, SyncTarget target, CancellationToken cancellationToken)
private async Task<SendFileResult> SendFile(IServerSyncProvider provider, string inputPath, LocalItem item, SyncTarget target, CancellationToken cancellationToken)
{
using (var stream = _fileSystem.GetFileStream(inputPath, FileMode.Open, FileAccess.Read, FileShare.Read, true))
{
await provider.SendFile(stream, item.LocalPath, target, new Progress<double>(), cancellationToken).ConfigureAwait(false);
return await provider.SendFile(stream, item.LocalPath, target, new Progress<double>(), cancellationToken).ConfigureAwait(false);
}
}

View File

@@ -581,6 +581,8 @@ namespace MediaBrowser.Server.Implementations.Sync
jobItem.MediaSource = mediaSource;
}
jobItem.MediaSource.SupportsTranscoding = false;
if (externalSubs.Count > 0)
{
// Save the job item now since conversion could take a while
@@ -757,6 +759,8 @@ namespace MediaBrowser.Server.Implementations.Sync
jobItem.MediaSource = mediaSource;
}
jobItem.MediaSource.SupportsTranscoding = false;
jobItem.Progress = 50;
jobItem.Status = SyncJobItemStatus.ReadyToTransfer;
await _syncManager.UpdateSyncJobItemInternal(jobItem).ConfigureAwait(false);

View File

@@ -3,11 +3,9 @@ using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Sync;
using MediaBrowser.Model.Dto;
using MediaBrowser.Model.MediaInfo;
using MediaBrowser.Model.Sync;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
@@ -58,7 +56,7 @@ namespace MediaBrowser.Server.Implementations.Sync
foreach (var localItem in localItems)
{
list.AddRange(GetPlayableMediaSources(localItem));
list.AddRange(localItem.Item.MediaSources);
}
}
}
@@ -66,24 +64,5 @@ namespace MediaBrowser.Server.Implementations.Sync
return list;
}
private IEnumerable<MediaSourceInfo> GetPlayableMediaSources(LocalItem item)
{
return item.Item.MediaSources
.Where(IsMediaSourcePlayable);
}
private bool IsMediaSourcePlayable(MediaSourceInfo mediaSource)
{
if (mediaSource.Protocol == MediaProtocol.File)
{
if (!File.Exists(mediaSource.Path))
{
return false;
}
}
return true;
}
}
}