The Free Software Media System - Server Backend & API
update recording deletion process
Luke Pulverentib30bd9a1dfc5
diff --git a/MediaBrowser.Api/Library/LibraryService.cs b/MediaBrowser.Api/Library/LibraryService.csindex 0563727d98..896f8c9908 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.Libraryreturn 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.csindex 379697b816..d52e2b37fb 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 filediff --git a/MediaBrowser.Controller/Library/LibraryManagerExtensions.cs b/MediaBrowser.Controller/Library/LibraryManagerExtensions.csindex dd1c9c07a9..4c9831bf94 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.csindex 241b01405a..3d9354433f 100644--- a/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs+++ b/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs@@ -44,6 +44,13 @@ namespace MediaBrowser.Controller.LiveTv/// <returns>Task.</returns>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>diff --git a/MediaBrowser.Controller/LiveTv/LiveTvAudioRecording.cs b/MediaBrowser.Controller/LiveTv/LiveTvAudioRecording.csindex d9834c191b..c3d843f85a 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.csindex c58b5502b2..5492a29f30 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.Providers/TV/DummySeasonProvider.cs b/MediaBrowser.Providers/TV/DummySeasonProvider.csindex 0faaaa702b..d4e4b48445 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.csindex 9c0e0b8731..ff31dbc920 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.csindex dcebc0c42e..b21e439a68 100644--- a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs+++ b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs@@ -1673,6 +1673,11 @@ namespace MediaBrowser.Server.Implementations.LiveTvthrow 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 serviceawait _libraryManager.DeleteItem((BaseItem)recording, new DeleteOptions{diff --git a/MediaBrowser.Server.Implementations/Persistence/CleanDatabaseScheduledTask.cs b/MediaBrowser.Server.Implementations/Persistence/CleanDatabaseScheduledTask.csindex 0959e2123c..6ca1bae6db 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){