diff options
| author | Luke Pulverenti <luke.pulverenti@gmail.com> | 2014-12-28 01:21:39 -0500 |
|---|---|---|
| committer | Luke Pulverenti <luke.pulverenti@gmail.com> | 2014-12-28 01:21:39 -0500 |
| commit | 5278959edef763bdf0b4d72ace75efd151ab5024 (patch) | |
| tree | acdcd09a21cd3f549a086589e89656181df56bf5 /MediaBrowser.Server.Implementations/Sync | |
| parent | 7bce2e04b618671faafc32a39978d0d8c87cba21 (diff) | |
sync fixes
Diffstat (limited to 'MediaBrowser.Server.Implementations/Sync')
3 files changed, 64 insertions, 42 deletions
diff --git a/MediaBrowser.Server.Implementations/Sync/SyncJobProcessor.cs b/MediaBrowser.Server.Implementations/Sync/SyncJobProcessor.cs index 5c933b4bd..5e129d9a1 100644 --- a/MediaBrowser.Server.Implementations/Sync/SyncJobProcessor.cs +++ b/MediaBrowser.Server.Implementations/Sync/SyncJobProcessor.cs @@ -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) - { - jobItem.OutputPath = await Sync(jobItem, (Game)item, deviceProfile, cancellationToken).ConfigureAwait(false); - } - - else if (item is Book) + else { - jobItem.OutputPath = await Sync(jobItem, (Book)item, deviceProfile, cancellationToken).ConfigureAwait(false); + await SyncGeneric(jobItem, 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; - private async Task<string> Sync(SyncJobItem jobItem, Photo 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> Sync(SyncJobItem jobItem, Game 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, Book item, DeviceProfile profile, CancellationToken cancellationToken) + private async Task SyncGeneric(SyncJobItem jobItem, BaseItem 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> DownloadFile(SyncJobItem jobItem, MediaSourceInfo mediaSource, CancellationToken cancellationToken) diff --git a/MediaBrowser.Server.Implementations/Sync/SyncManager.cs b/MediaBrowser.Server.Implementations/Sync/SyncManager.cs index 22d0ee5e7..24b9b0b83 100644 --- a/MediaBrowser.Server.Implementations/Sync/SyncManager.cs +++ b/MediaBrowser.Server.Implementations/Sync/SyncManager.cs @@ -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(); } } } diff --git a/MediaBrowser.Server.Implementations/Sync/SyncRepository.cs b/MediaBrowser.Server.Implementations/Sync/SyncRepository.cs index a981ffc57..e5b323725 100644 --- a/MediaBrowser.Server.Implementations/Sync/SyncRepository.cs +++ b/MediaBrowser.Server.Implementations/Sync/SyncRepository.cs @@ -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; |
