mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-03-12 21:26:17 +00:00
sync fixes
This commit is contained in:
@@ -316,35 +316,26 @@ namespace MediaBrowser.Server.Implementations.Sync
|
||||
var video = item as Video;
|
||||
if (video != null)
|
||||
{
|
||||
jobItem.OutputPath = await Sync(jobItem, video, deviceProfile, cancellationToken).ConfigureAwait(false);
|
||||
await Sync(jobItem, video, deviceProfile, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
else if (item is Audio)
|
||||
{
|
||||
jobItem.OutputPath = await Sync(jobItem, (Audio)item, deviceProfile, cancellationToken).ConfigureAwait(false);
|
||||
await Sync(jobItem, (Audio)item, deviceProfile, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
else if (item is Photo)
|
||||
{
|
||||
jobItem.OutputPath = await Sync(jobItem, (Photo)item, deviceProfile, cancellationToken).ConfigureAwait(false);
|
||||
await Sync(jobItem, (Photo)item, deviceProfile, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
else if (item is Game)
|
||||
else
|
||||
{
|
||||
jobItem.OutputPath = await Sync(jobItem, (Game)item, deviceProfile, cancellationToken).ConfigureAwait(false);
|
||||
await SyncGeneric(jobItem, item, deviceProfile, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
else if (item is Book)
|
||||
{
|
||||
jobItem.OutputPath = await Sync(jobItem, (Book)item, deviceProfile, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
jobItem.Progress = 50;
|
||||
jobItem.Status = SyncJobItemStatus.Transferring;
|
||||
await _syncRepo.Update(jobItem).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
private async Task<string> Sync(SyncJobItem jobItem, Video item, DeviceProfile profile, CancellationToken cancellationToken)
|
||||
private async Task Sync(SyncJobItem jobItem, Video item, DeviceProfile profile, CancellationToken cancellationToken)
|
||||
{
|
||||
var options = new VideoOptions
|
||||
{
|
||||
@@ -359,26 +350,33 @@ namespace MediaBrowser.Server.Implementations.Sync
|
||||
var mediaSource = streamInfo.MediaSource;
|
||||
|
||||
jobItem.MediaSourceId = streamInfo.MediaSourceId;
|
||||
await _syncRepo.Update(jobItem).ConfigureAwait(false);
|
||||
|
||||
if (streamInfo.PlayMethod != PlayMethod.Transcode)
|
||||
if (streamInfo.PlayMethod == PlayMethod.Transcode)
|
||||
{
|
||||
await _syncRepo.Update(jobItem).ConfigureAwait(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (mediaSource.Protocol == MediaProtocol.File)
|
||||
{
|
||||
return mediaSource.Path;
|
||||
jobItem.OutputPath = mediaSource.Path;
|
||||
}
|
||||
if (mediaSource.Protocol == MediaProtocol.Http)
|
||||
{
|
||||
return await DownloadFile(jobItem, mediaSource, cancellationToken).ConfigureAwait(false);
|
||||
jobItem.OutputPath = await DownloadFile(jobItem, mediaSource, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
throw new InvalidOperationException(string.Format("Cannot direct stream {0} protocol", mediaSource.Protocol));
|
||||
}
|
||||
|
||||
// TODO: Transcode
|
||||
return mediaSource.Path;
|
||||
jobItem.OutputPath = mediaSource.Path;
|
||||
|
||||
jobItem.Progress = 50;
|
||||
jobItem.Status = SyncJobItemStatus.Transferring;
|
||||
await _syncRepo.Update(jobItem).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
private async Task<string> Sync(SyncJobItem jobItem, Audio item, DeviceProfile profile, CancellationToken cancellationToken)
|
||||
private async Task Sync(SyncJobItem jobItem, Audio item, DeviceProfile profile, CancellationToken cancellationToken)
|
||||
{
|
||||
var options = new AudioOptions
|
||||
{
|
||||
@@ -393,38 +391,48 @@ namespace MediaBrowser.Server.Implementations.Sync
|
||||
var mediaSource = streamInfo.MediaSource;
|
||||
|
||||
jobItem.MediaSourceId = streamInfo.MediaSourceId;
|
||||
await _syncRepo.Update(jobItem).ConfigureAwait(false);
|
||||
|
||||
if (streamInfo.PlayMethod != PlayMethod.Transcode)
|
||||
if (streamInfo.PlayMethod == PlayMethod.Transcode)
|
||||
{
|
||||
await _syncRepo.Update(jobItem).ConfigureAwait(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (mediaSource.Protocol == MediaProtocol.File)
|
||||
{
|
||||
return mediaSource.Path;
|
||||
jobItem.OutputPath = mediaSource.Path;
|
||||
}
|
||||
if (mediaSource.Protocol == MediaProtocol.Http)
|
||||
{
|
||||
return await DownloadFile(jobItem, mediaSource, cancellationToken).ConfigureAwait(false);
|
||||
jobItem.OutputPath = await DownloadFile(jobItem, mediaSource, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
throw new InvalidOperationException(string.Format("Cannot direct stream {0} protocol", mediaSource.Protocol));
|
||||
}
|
||||
|
||||
// TODO: Transcode
|
||||
return mediaSource.Path;
|
||||
jobItem.OutputPath = mediaSource.Path;
|
||||
|
||||
jobItem.Progress = 50;
|
||||
jobItem.Status = SyncJobItemStatus.Transferring;
|
||||
await _syncRepo.Update(jobItem).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
private async Task<string> Sync(SyncJobItem jobItem, Photo item, DeviceProfile profile, CancellationToken cancellationToken)
|
||||
private async Task Sync(SyncJobItem jobItem, Photo item, DeviceProfile profile, CancellationToken cancellationToken)
|
||||
{
|
||||
return item.Path;
|
||||
jobItem.OutputPath = item.Path;
|
||||
|
||||
jobItem.Progress = 50;
|
||||
jobItem.Status = SyncJobItemStatus.Transferring;
|
||||
await _syncRepo.Update(jobItem).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
private async Task<string> Sync(SyncJobItem jobItem, Game item, DeviceProfile profile, CancellationToken cancellationToken)
|
||||
private async Task SyncGeneric(SyncJobItem jobItem, BaseItem item, DeviceProfile profile, CancellationToken cancellationToken)
|
||||
{
|
||||
return item.Path;
|
||||
}
|
||||
jobItem.OutputPath = item.Path;
|
||||
|
||||
private async Task<string> Sync(SyncJobItem jobItem, Book item, DeviceProfile profile, CancellationToken cancellationToken)
|
||||
{
|
||||
return item.Path;
|
||||
jobItem.Progress = 50;
|
||||
jobItem.Status = SyncJobItemStatus.Transferring;
|
||||
await _syncRepo.Update(jobItem).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
private async Task<string> DownloadFile(SyncJobItem jobItem, MediaSourceInfo mediaSource, CancellationToken cancellationToken)
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System.IO;
|
||||
using MediaBrowser.Common;
|
||||
using MediaBrowser.Common;
|
||||
using MediaBrowser.Common.Extensions;
|
||||
using MediaBrowser.Controller.Channels;
|
||||
using MediaBrowser.Controller.Drawing;
|
||||
@@ -20,6 +19,7 @@ using MediaBrowser.Model.Users;
|
||||
using MoreLinq;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
@@ -337,7 +337,19 @@ namespace MediaBrowser.Server.Implementations.Sync
|
||||
UserId = job.UserId
|
||||
};
|
||||
|
||||
syncedItem.Item = _dtoService().GetBaseItemDto(libraryItem, new DtoOptions());
|
||||
var dtoOptions = new DtoOptions();
|
||||
|
||||
// Remove some bloat
|
||||
dtoOptions.Fields.Remove(ItemFields.MediaStreams);
|
||||
dtoOptions.Fields.Remove(ItemFields.IndexOptions);
|
||||
dtoOptions.Fields.Remove(ItemFields.MediaSourceCount);
|
||||
dtoOptions.Fields.Remove(ItemFields.OriginalPrimaryImageAspectRatio);
|
||||
dtoOptions.Fields.Remove(ItemFields.Path);
|
||||
dtoOptions.Fields.Remove(ItemFields.SeriesGenres);
|
||||
dtoOptions.Fields.Remove(ItemFields.Settings);
|
||||
dtoOptions.Fields.Remove(ItemFields.SyncInfo);
|
||||
|
||||
syncedItem.Item = _dtoService().GetBaseItemDto(libraryItem, dtoOptions);
|
||||
|
||||
// TODO: this should be the media source of the transcoded output
|
||||
syncedItem.Item.MediaSources = syncedItem.Item.MediaSources
|
||||
@@ -370,10 +382,11 @@ namespace MediaBrowser.Server.Implementations.Sync
|
||||
var jobItemResult = GetJobItems(new SyncJobItemQuery
|
||||
{
|
||||
TargetId = targetId,
|
||||
//Status = SyncJobItemStatus.Transferring
|
||||
Status = SyncJobItemStatus.Transferring
|
||||
});
|
||||
|
||||
return jobItemResult.Items.Select(GetJobItemInfo).ToList();
|
||||
return jobItemResult.Items.Select(GetJobItemInfo)
|
||||
.ToList();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -227,7 +227,7 @@ namespace MediaBrowser.Server.Implementations.Sync
|
||||
_saveJobCommand.GetParameter(index++).Value = job.TargetId;
|
||||
_saveJobCommand.GetParameter(index++).Value = job.Name;
|
||||
_saveJobCommand.GetParameter(index++).Value = job.Quality;
|
||||
_saveJobCommand.GetParameter(index++).Value = job.Status;
|
||||
_saveJobCommand.GetParameter(index++).Value = job.Status.ToString();
|
||||
_saveJobCommand.GetParameter(index++).Value = job.Progress;
|
||||
_saveJobCommand.GetParameter(index++).Value = job.UserId;
|
||||
_saveJobCommand.GetParameter(index++).Value = string.Join(",", job.RequestedItemIds.ToArray());
|
||||
@@ -466,13 +466,14 @@ namespace MediaBrowser.Server.Implementations.Sync
|
||||
whereClauses.Add("TargetId=@TargetId");
|
||||
cmd.Parameters.Add(cmd, "@TargetId", DbType.String).Value = query.TargetId;
|
||||
}
|
||||
|
||||
if (query.Status.HasValue)
|
||||
{
|
||||
whereClauses.Add("Status=@Status");
|
||||
cmd.Parameters.Add(cmd, "@Status", DbType.String).Value = query.Status.Value.ToString();
|
||||
}
|
||||
|
||||
if (query.IsCompleted.HasValue)
|
||||
else if (query.IsCompleted.HasValue)
|
||||
{
|
||||
if (query.IsCompleted.Value)
|
||||
{
|
||||
@@ -561,7 +562,7 @@ namespace MediaBrowser.Server.Implementations.Sync
|
||||
_saveJobItemCommand.GetParameter(index++).Value = jobItem.MediaSourceId;
|
||||
_saveJobItemCommand.GetParameter(index++).Value = jobItem.JobId;
|
||||
_saveJobItemCommand.GetParameter(index++).Value = jobItem.OutputPath;
|
||||
_saveJobItemCommand.GetParameter(index++).Value = jobItem.Status;
|
||||
_saveJobItemCommand.GetParameter(index++).Value = jobItem.Status.ToString();
|
||||
_saveJobItemCommand.GetParameter(index++).Value = jobItem.TargetId;
|
||||
_saveJobItemCommand.GetParameter(index++).Value = jobItem.DateCreated;
|
||||
_saveJobItemCommand.GetParameter(index++).Value = jobItem.Progress;
|
||||
|
||||
Reference in New Issue
Block a user