The Free Software Media System - Server Backend & API
Validate Collection Folders on adding and removal (#11444)
gnattu3ae0fb90cba3
diff --git a/Emby.Server.Implementations/Library/LibraryManager.cs b/Emby.Server.Implementations/Library/LibraryManager.csindex 3b5714f8e5..cca835e4fa 100644--- a/Emby.Server.Implementations/Library/LibraryManager.cs+++ b/Emby.Server.Implementations/Library/LibraryManager.cs@@ -1038,6 +1038,7 @@ namespace Emby.Server.Implementations.Librarynew Progress<double>(),new MetadataRefreshOptions(new DirectoryService(_fileSystem)),recursive: false,+ allowRemoveRoot: removeRoot,cancellationToken: cancellationToken).ConfigureAwait(false);await GetUserRootFolder().RefreshMetadata(cancellationToken).ConfigureAwait(false);diff --git a/MediaBrowser.Controller/Entities/AggregateFolder.cs b/MediaBrowser.Controller/Entities/AggregateFolder.csindex 70c33a8c4c..40cdd6c91e 100644--- a/MediaBrowser.Controller/Entities/AggregateFolder.cs+++ b/MediaBrowser.Controller/Entities/AggregateFolder.cs@@ -159,7 +159,7 @@ namespace MediaBrowser.Controller.Entities{ClearCache();- await base.ValidateChildrenInternal(progress, recursive, refreshChildMetadata, false, refreshOptions, directoryService, cancellationToken)+ await base.ValidateChildrenInternal(progress, recursive, refreshChildMetadata, allowRemoveRoot, refreshOptions, directoryService, cancellationToken).ConfigureAwait(false);ClearCache();diff --git a/MediaBrowser.Controller/Entities/Folder.cs b/MediaBrowser.Controller/Entities/Folder.csindex 45c27fdc02..f39fa79eb4 100644--- a/MediaBrowser.Controller/Entities/Folder.cs+++ b/MediaBrowser.Controller/Entities/Folder.cs@@ -333,8 +333,13 @@ namespace MediaBrowser.Controller.Entities}}- private static bool IsLibraryFolderAccessible(IDirectoryService directoryService, BaseItem item)+ private static bool IsLibraryFolderAccessible(IDirectoryService directoryService, BaseItem item, bool checkCollection){+ if (!checkCollection && (item is BoxSet || string.Equals(item.FileNameWithoutExtension, "collections", StringComparison.OrdinalIgnoreCase)))+ {+ return true;+ }+// For top parents i.e. Library folders, skip the validation if it's empty or inaccessibleif (item.IsTopParent && !directoryService.IsAccessible(item.ContainingFolderPath)){@@ -347,7 +352,7 @@ namespace MediaBrowser.Controller.Entitiesprivate async Task ValidateChildrenInternal2(IProgress<double> progress, bool recursive, bool refreshChildMetadata, bool allowRemoveRoot, MetadataRefreshOptions refreshOptions, IDirectoryService directoryService, CancellationToken cancellationToken){- if (!IsLibraryFolderAccessible(directoryService, this))+ if (!IsLibraryFolderAccessible(directoryService, this, allowRemoveRoot)){return;}@@ -388,7 +393,7 @@ namespace MediaBrowser.Controller.Entitiesforeach (var child in nonCachedChildren){- if (!IsLibraryFolderAccessible(directoryService, child))+ if (!IsLibraryFolderAccessible(directoryService, child, allowRemoveRoot)){continue;}