Skip to content

Commit

Permalink
fix: remove VFS library roots with the same id but wrong parent folder
Browse files Browse the repository at this point in the history
- Remove any and all VFS library roots from the library with the correct library ID but the wrong parent folder(s).
  • Loading branch information
revam committed Oct 9, 2024
1 parent 3369217 commit 8ec4bcc
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion Shokofin/Configuration/MediaFolderConfigurationService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,7 @@ private async Task GenerateAllConfigurations(List<VirtualFolderInfo> allVirtualF
continue;

var vfsPath = libraryFolder.GetVirtualRoot();
var vfsFolderName = Path.GetFileName(vfsPath);
var shouldAttach = config.VFS_AttachRoot && mediaFolderConfig.IsVirtualFileSystemEnabled;
if (shouldAttach && !virtualFolder.Locations.Contains(vfsPath, Path.DirectorySeparatorChar is '\\' ? StringComparer.OrdinalIgnoreCase : StringComparer.Ordinal)) {
if (!LibraryEdits.TryGetValue(libraryId, out var edits))
Expand All @@ -339,7 +340,11 @@ private async Task GenerateAllConfigurations(List<VirtualFolderInfo> allVirtualF

var toRemove = virtualFolder.Locations
.Except(shouldAttach ? [vfsPath] : [])
.Where(location => Plugin.Instance.AllVirtualRoots.Any(virtualRoot => location.StartsWith(virtualRoot, Path.DirectorySeparatorChar is '\\' ? StringComparison.OrdinalIgnoreCase : StringComparison.Ordinal)))
.Where(location =>
// In case the VFS root changes.
(string.Equals(Path.GetFileName(location), vfsFolderName) && !string.Equals(location, vfsPath)) ||
// In case the libraryId changes but the root remains the same.
Plugin.Instance.AllVirtualRoots.Any(virtualRoot => location.StartsWith(virtualRoot, Path.DirectorySeparatorChar is '\\' ? StringComparison.OrdinalIgnoreCase : StringComparison.Ordinal)))
.ToList();
if (toRemove.Count > 0) {
if (!LibraryEdits.TryGetValue(libraryId, out var edits))
Expand Down

0 comments on commit 8ec4bcc

Please sign in to comment.