fix: mark UserRoot as non-root when performing removal

Fixes #11269

Signed-off-by: gnattu <gnattuoc@me.com>
pull/11352/head
gnattu 7 months ago
parent c566ccb63b
commit 204146a3a5

@ -1033,7 +1033,7 @@ namespace Emby.Server.Implementations.Library
} }
} }
private async Task ValidateTopLibraryFolders(CancellationToken cancellationToken) private async Task ValidateTopLibraryFolders(CancellationToken cancellationToken, bool removeRoot = false)
{ {
await RootFolder.RefreshMetadata(cancellationToken).ConfigureAwait(false); await RootFolder.RefreshMetadata(cancellationToken).ConfigureAwait(false);
@ -1046,11 +1046,15 @@ namespace Emby.Server.Implementations.Library
await GetUserRootFolder().RefreshMetadata(cancellationToken).ConfigureAwait(false); await GetUserRootFolder().RefreshMetadata(cancellationToken).ConfigureAwait(false);
// HACK: override IsRootHere for libraries to be removed
if (removeRoot) GetUserRootFolder().IsRoot = false;
await GetUserRootFolder().ValidateChildren( await GetUserRootFolder().ValidateChildren(
new Progress<double>(), new Progress<double>(),
new MetadataRefreshOptions(new DirectoryService(_fileSystem)), new MetadataRefreshOptions(new DirectoryService(_fileSystem)),
recursive: false, recursive: false,
cancellationToken).ConfigureAwait(false); cancellationToken).ConfigureAwait(false);
// HACK: restore IsRoot here after validation
if (removeRoot) GetUserRootFolder().IsRoot = true;
// Quickly scan CollectionFolders for changes // Quickly scan CollectionFolders for changes
foreach (var folder in GetUserRootFolder().Children.OfType<Folder>()) foreach (var folder in GetUserRootFolder().Children.OfType<Folder>())
@ -3118,7 +3122,7 @@ namespace Emby.Server.Implementations.Library
if (refreshLibrary) if (refreshLibrary)
{ {
await ValidateTopLibraryFolders(CancellationToken.None).ConfigureAwait(false); await ValidateTopLibraryFolders(CancellationToken.None, true).ConfigureAwait(false);
StartScanInBackground(); StartScanInBackground();
} }

Loading…
Cancel
Save