diff options
| author | Luke <luke.pulverenti@gmail.com> | 2016-02-11 23:59:22 -0500 |
|---|---|---|
| committer | Luke <luke.pulverenti@gmail.com> | 2016-02-11 23:59:22 -0500 |
| commit | 6f2d87a0f98704f63f8d37229017cdb8fae1acf1 (patch) | |
| tree | b2b78015920018c0d701c94fdcd8510d9239bc0a | |
| parent | cec3d7e6b4cb2805e9fa0b1028d0dbb8eb3d95fb (diff) | |
| parent | b30bd9a1dfc52ff4581183acf5ddb214efc518da (diff) | |
Merge pull request #1444 from MediaBrowser/dev
Dev
15 files changed, 66 insertions, 31 deletions
diff --git a/MediaBrowser.Api/Library/LibraryService.cs b/MediaBrowser.Api/Library/LibraryService.cs index 0563727d9..896f8c990 100644 --- a/MediaBrowser.Api/Library/LibraryService.cs +++ b/MediaBrowser.Api/Library/LibraryService.cs @@ -569,7 +569,7 @@ namespace MediaBrowser.Api.Library { throw new ArgumentException("This command cannot be used for remote or virtual items."); } - if (_fileSystem.DirectoryExists(item.Path)) + if (_fileSystem.DirectoryExists(item.Path)) { throw new ArgumentException("This command cannot be used for directories."); } @@ -789,12 +789,10 @@ namespace MediaBrowser.Api.Library return Task.FromResult(true); } - if (item is ILiveTvRecording) + return item.Delete(new DeleteOptions { - return _liveTv.DeleteRecording(i); - } - - return _libraryManager.DeleteItem(item); + DeleteFileLocation = true + }); }).ToArray(); Task.WaitAll(tasks); diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.cs index 379697b81..d52e2b37f 100644 --- a/MediaBrowser.Controller/Entities/BaseItem.cs +++ b/MediaBrowser.Controller/Entities/BaseItem.cs @@ -1980,5 +1980,10 @@ namespace MediaBrowser.Controller.Entities { return new[] { Id }; } + + public virtual Task Delete(DeleteOptions options) + { + return LibraryManager.DeleteItem(this, options); + } } }
\ No newline at end of file diff --git a/MediaBrowser.Controller/Library/LibraryManagerExtensions.cs b/MediaBrowser.Controller/Library/LibraryManagerExtensions.cs index dd1c9c07a..4c9831bf9 100644 --- a/MediaBrowser.Controller/Library/LibraryManagerExtensions.cs +++ b/MediaBrowser.Controller/Library/LibraryManagerExtensions.cs @@ -6,14 +6,6 @@ namespace MediaBrowser.Controller.Library { public static class LibraryManagerExtensions { - public static Task DeleteItem(this ILibraryManager manager, BaseItem item) - { - return manager.DeleteItem(item, new DeleteOptions - { - DeleteFileLocation = true - }); - } - public static BaseItem GetItemById(this ILibraryManager manager, string id) { return manager.GetItemById(new Guid(id)); diff --git a/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs b/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs index 241b01405..3d9354433 100644 --- a/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs +++ b/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs @@ -45,6 +45,13 @@ namespace MediaBrowser.Controller.LiveTv Task DeleteRecording(string id); /// <summary> + /// Deletes the recording. + /// </summary> + /// <param name="recording">The recording.</param> + /// <returns>Task.</returns> + Task DeleteRecording(ILiveTvRecording recording); + + /// <summary> /// Cancels the timer. /// </summary> /// <param name="id">The identifier.</param> diff --git a/MediaBrowser.Controller/LiveTv/LiveTvAudioRecording.cs b/MediaBrowser.Controller/LiveTv/LiveTvAudioRecording.cs index d9834c191..c3d843f85 100644 --- a/MediaBrowser.Controller/LiveTv/LiveTvAudioRecording.cs +++ b/MediaBrowser.Controller/LiveTv/LiveTvAudioRecording.cs @@ -9,6 +9,8 @@ using System; using System.Collections.Generic; using System.Linq; using System.Runtime.Serialization; +using System.Threading.Tasks; +using MediaBrowser.Controller.Library; namespace MediaBrowser.Controller.LiveTv { @@ -144,5 +146,10 @@ namespace MediaBrowser.Controller.LiveTv { return IsVisible(user); } + + public override Task Delete(DeleteOptions options) + { + return LiveTvManager.DeleteRecording(this); + } } } diff --git a/MediaBrowser.Controller/LiveTv/LiveTvVideoRecording.cs b/MediaBrowser.Controller/LiveTv/LiveTvVideoRecording.cs index c58b5502b..5492a29f3 100644 --- a/MediaBrowser.Controller/LiveTv/LiveTvVideoRecording.cs +++ b/MediaBrowser.Controller/LiveTv/LiveTvVideoRecording.cs @@ -9,6 +9,8 @@ using System; using System.Collections.Generic; using System.Linq; using System.Runtime.Serialization; +using System.Threading.Tasks; +using MediaBrowser.Controller.Library; namespace MediaBrowser.Controller.LiveTv { @@ -159,5 +161,10 @@ namespace MediaBrowser.Controller.LiveTv { return IsVisible(user); } + + public override Task Delete(DeleteOptions options) + { + return LiveTvManager.DeleteRecording(this); + } } } diff --git a/MediaBrowser.Dlna/PlayTo/SsdpHttpClient.cs b/MediaBrowser.Dlna/PlayTo/SsdpHttpClient.cs index ab6674afc..ff4223c72 100644 --- a/MediaBrowser.Dlna/PlayTo/SsdpHttpClient.cs +++ b/MediaBrowser.Dlna/PlayTo/SsdpHttpClient.cs @@ -114,7 +114,7 @@ namespace MediaBrowser.Dlna.PlayTo { Url = url, UserAgent = USERAGENT, - LogRequest = logRequest || _config.GetDlnaConfiguration().EnableDebugLogging, + LogRequest = logRequest || _config.GetDlnaConfiguration().EnableDebugLog, LogErrorResponseBody = true }; diff --git a/MediaBrowser.Dlna/Service/BaseControlHandler.cs b/MediaBrowser.Dlna/Service/BaseControlHandler.cs index a65520d65..c5de76eb5 100644 --- a/MediaBrowser.Dlna/Service/BaseControlHandler.cs +++ b/MediaBrowser.Dlna/Service/BaseControlHandler.cs @@ -27,7 +27,7 @@ namespace MediaBrowser.Dlna.Service { try { - var enableDebugLogging = Config.GetDlnaConfiguration().EnableDebugLogging; + var enableDebugLogging = Config.GetDlnaConfiguration().EnableDebugLog; if (enableDebugLogging) { diff --git a/MediaBrowser.Dlna/Ssdp/DeviceDiscovery.cs b/MediaBrowser.Dlna/Ssdp/DeviceDiscovery.cs index ed3698e43..4f7dffdd9 100644 --- a/MediaBrowser.Dlna/Ssdp/DeviceDiscovery.cs +++ b/MediaBrowser.Dlna/Ssdp/DeviceDiscovery.cs @@ -217,7 +217,7 @@ namespace MediaBrowser.Dlna.Ssdp return; } - if (_config.GetDlnaConfiguration().EnableDebugLogging) + if (_config.GetDlnaConfiguration().EnableDebugLog) { var headerTexts = args.Headers.Select(i => string.Format("{0}={1}", i.Key, i.Value)); var headerText = string.Join(",", headerTexts.ToArray()); diff --git a/MediaBrowser.Dlna/Ssdp/SsdpHandler.cs b/MediaBrowser.Dlna/Ssdp/SsdpHandler.cs index f800a12c1..d755d2f58 100644 --- a/MediaBrowser.Dlna/Ssdp/SsdpHandler.cs +++ b/MediaBrowser.Dlna/Ssdp/SsdpHandler.cs @@ -92,7 +92,7 @@ namespace MediaBrowser.Dlna.Ssdp { TimeSpan delay = GetSearchDelay(headers); - if (_config.GetDlnaConfiguration().EnableDebugLogging) + if (_config.GetDlnaConfiguration().EnableDebugLog) { _logger.Debug("Delaying search response by {0} seconds", delay.TotalSeconds); } @@ -163,7 +163,7 @@ namespace MediaBrowser.Dlna.Ssdp { var msg = new SsdpMessageBuilder().BuildMessage(header, values); - var enableDebugLogging = _config.GetDlnaConfiguration().EnableDebugLogging; + var enableDebugLogging = _config.GetDlnaConfiguration().EnableDebugLog; for (var i = 0; i < sendCount; i++) { @@ -202,7 +202,7 @@ namespace MediaBrowser.Dlna.Ssdp private void RespondToSearch(EndPoint endpoint, string deviceType) { - var enableDebugLogging = _config.GetDlnaConfiguration().EnableDebugLogging; + var enableDebugLogging = _config.GetDlnaConfiguration().EnableDebugLog; var isLogged = false; @@ -305,7 +305,7 @@ namespace MediaBrowser.Dlna.Ssdp var received = (byte[])result.AsyncState; - var enableDebugLogging = _config.GetDlnaConfiguration().EnableDebugLogging; + var enableDebugLogging = _config.GetDlnaConfiguration().EnableDebugLog; if (enableDebugLogging) { @@ -404,7 +404,7 @@ namespace MediaBrowser.Dlna.Ssdp private void NotifyAll() { - var enableDebugLogging = _config.GetDlnaConfiguration().EnableDebugLogging; + var enableDebugLogging = _config.GetDlnaConfiguration().EnableDebugLog; if (enableDebugLogging) { diff --git a/MediaBrowser.Model/Configuration/DlnaOptions.cs b/MediaBrowser.Model/Configuration/DlnaOptions.cs index c1974b877..6eaf01c4a 100644 --- a/MediaBrowser.Model/Configuration/DlnaOptions.cs +++ b/MediaBrowser.Model/Configuration/DlnaOptions.cs @@ -5,7 +5,7 @@ namespace MediaBrowser.Model.Configuration { public bool EnablePlayTo { get; set; } public bool EnableServer { get; set; } - public bool EnableDebugLogging { get; set; } + public bool EnableDebugLog { get; set; } public bool BlastAliveMessages { get; set; } public int ClientDiscoveryIntervalSeconds { get; set; } public int BlastAliveMessageIntervalSeconds { get; set; } diff --git a/MediaBrowser.Providers/TV/DummySeasonProvider.cs b/MediaBrowser.Providers/TV/DummySeasonProvider.cs index 0faaaa702..d4e4b4844 100644 --- a/MediaBrowser.Providers/TV/DummySeasonProvider.cs +++ b/MediaBrowser.Providers/TV/DummySeasonProvider.cs @@ -175,7 +175,11 @@ namespace MediaBrowser.Providers.TV { _logger.Info("Removing virtual season {0} {1}", seasonToRemove.Series.Name, seasonToRemove.IndexNumber); - await _libraryManager.DeleteItem(seasonToRemove).ConfigureAwait(false); + await seasonToRemove.Delete(new DeleteOptions + { + DeleteFileLocation = true + + }).ConfigureAwait(false); hasChanges = true; } diff --git a/MediaBrowser.Providers/TV/MissingEpisodeProvider.cs b/MediaBrowser.Providers/TV/MissingEpisodeProvider.cs index 9c0e0b873..ff31dbc92 100644 --- a/MediaBrowser.Providers/TV/MissingEpisodeProvider.cs +++ b/MediaBrowser.Providers/TV/MissingEpisodeProvider.cs @@ -315,7 +315,11 @@ namespace MediaBrowser.Providers.TV { _logger.Info("Removing missing/unaired episode {0} {1}x{2}", episodeToRemove.Series.Name, episodeToRemove.ParentIndexNumber, episodeToRemove.IndexNumber); - await _libraryManager.DeleteItem(episodeToRemove).ConfigureAwait(false); + await episodeToRemove.Delete(new DeleteOptions + { + DeleteFileLocation = true + + }).ConfigureAwait(false); hasChanges = true; } @@ -380,7 +384,11 @@ namespace MediaBrowser.Providers.TV { _logger.Info("Removing virtual season {0} {1}", seasonToRemove.Series.Name, seasonToRemove.IndexNumber); - await _libraryManager.DeleteItem(seasonToRemove).ConfigureAwait(false); + await seasonToRemove.Delete(new DeleteOptions + { + DeleteFileLocation = true + + }).ConfigureAwait(false); hasChanges = true; } diff --git a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs index dcebc0c42..b21e439a6 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs @@ -1673,6 +1673,11 @@ namespace MediaBrowser.Server.Implementations.LiveTv throw new ResourceNotFoundException(string.Format("Recording with Id {0} not found", recordingId)); } + await DeleteRecording(recording).ConfigureAwait(false); + } + + public async Task DeleteRecording(ILiveTvRecording recording) + { var service = GetService(recording.ServiceName); try @@ -1685,7 +1690,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv } _lastRecordingRefreshTime = DateTime.MinValue; - + // This is the responsibility of the live tv service await _libraryManager.DeleteItem((BaseItem)recording, new DeleteOptions { diff --git a/MediaBrowser.Server.Implementations/Persistence/CleanDatabaseScheduledTask.cs b/MediaBrowser.Server.Implementations/Persistence/CleanDatabaseScheduledTask.cs index 0959e2123..6ca1bae6d 100644 --- a/MediaBrowser.Server.Implementations/Persistence/CleanDatabaseScheduledTask.cs +++ b/MediaBrowser.Server.Implementations/Persistence/CleanDatabaseScheduledTask.cs @@ -205,10 +205,11 @@ namespace MediaBrowser.Server.Implementations.Persistence { _logger.Info("Cleaning item {0} type: {1} path: {2}", item.Name, item.GetType().Name, item.Path ?? string.Empty); - await _libraryManager.DeleteItem(item, new DeleteOptions + await item.Delete(new DeleteOptions { DeleteFileLocation = false - }); + + }).ConfigureAwait(false); } numComplete++; @@ -274,10 +275,11 @@ namespace MediaBrowser.Server.Implementations.Persistence _logger.Info("Deleting item from database {0} because path no longer exists. type: {1} path: {2}", libraryItem.Name, libraryItem.GetType().Name, libraryItem.Path ?? string.Empty); - await _libraryManager.DeleteItem(libraryItem, new DeleteOptions + await libraryItem.Delete(new DeleteOptions { DeleteFileLocation = false - }); + + }).ConfigureAwait(false); } catch (OperationCanceledException) { |
