diff options
Diffstat (limited to 'MediaBrowser.Server.Implementations/Persistence/CleanDatabaseScheduledTask.cs')
| -rw-r--r-- | MediaBrowser.Server.Implementations/Persistence/CleanDatabaseScheduledTask.cs | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/MediaBrowser.Server.Implementations/Persistence/CleanDatabaseScheduledTask.cs b/MediaBrowser.Server.Implementations/Persistence/CleanDatabaseScheduledTask.cs index 5f1bf0216..bec105b0a 100644 --- a/MediaBrowser.Server.Implementations/Persistence/CleanDatabaseScheduledTask.cs +++ b/MediaBrowser.Server.Implementations/Persistence/CleanDatabaseScheduledTask.cs @@ -208,7 +208,7 @@ namespace MediaBrowser.Server.Implementations.Persistence await item.Delete(new DeleteOptions { DeleteFileLocation = false - + }).ConfigureAwait(false); } @@ -225,7 +225,7 @@ namespace MediaBrowser.Server.Implementations.Persistence { var result = _itemRepo.GetItemIdsWithPath(new InternalItemsQuery { - LocationType = LocationType.FileSystem, + LocationTypes = new[] { LocationType.FileSystem }, //Limit = limit, // These have their own cleanup routines @@ -239,11 +239,7 @@ namespace MediaBrowser.Server.Implementations.Persistence typeof(Year).Name, typeof(Channel).Name, typeof(AggregateFolder).Name, - typeof(CollectionFolder).Name, - - // LiveTVManager handles recordings - typeof(LiveTvAudioRecording).Name, - typeof(LiveTvVideoRecording).Name + typeof(CollectionFolder).Name } }); @@ -270,6 +266,19 @@ namespace MediaBrowser.Server.Implementations.Persistence continue; } + var hasDualAccess = libraryItem as IHasDualAccess; + if (hasDualAccess != null && hasDualAccess.IsAccessedByName) + { + continue; + } + + var libraryItemPath = libraryItem.Path; + if (!string.Equals(libraryItemPath, path, StringComparison.OrdinalIgnoreCase)) + { + _logger.Error("CleanDeletedItems aborting delete for item {0}-{1} because paths don't match. {2}---{3}", libraryItem.Id, libraryItem.Name, libraryItem.Path ?? string.Empty, path ?? string.Empty); + continue; + } + if (Folder.IsPathOffline(path)) { libraryItem.IsOffline = true; @@ -277,13 +286,9 @@ namespace MediaBrowser.Server.Implementations.Persistence continue; } - _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); + _logger.Info("Deleting item from database {0} because path no longer exists. type: {1} path: {2}", libraryItem.Name, libraryItem.GetType().Name, libraryItemPath ?? string.Empty); - await libraryItem.Delete(new DeleteOptions - { - DeleteFileLocation = false - - }).ConfigureAwait(false); + await libraryItem.OnFileDeleted().ConfigureAwait(false); } catch (OperationCanceledException) { |
