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/SyncJobProcessor.cs | |
| parent | 7bce2e04b618671faafc32a39978d0d8c87cba21 (diff) | |
sync fixes
Diffstat (limited to 'MediaBrowser.Server.Implementations/Sync/SyncJobProcessor.cs')
| -rw-r--r-- | MediaBrowser.Server.Implementations/Sync/SyncJobProcessor.cs | 76 |
1 files changed, 42 insertions, 34 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) |
