mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-03-19 16:46:36 +00:00
update server sync
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user