diff --git a/Shokofin/Resolvers/VirtualFileSystemService.cs b/Shokofin/Resolvers/VirtualFileSystemService.cs
index 4216927b..f1ad5d73 100644
--- a/Shokofin/Resolvers/VirtualFileSystemService.cs
+++ b/Shokofin/Resolvers/VirtualFileSystemService.cs
@@ -131,7 +131,6 @@ private void OnLibraryManagerItemRemoved(object? sender, ItemChangeEventArgs e)
/// The VFS path, if it succeeded.
public async Task GenerateStructureInVFS(Folder mediaFolder, string path)
{
- // Skip link generation if we've already generated for the media folder.
var (vfsPath, collectionType, mediaConfigs) = ConfigurationService.GetAvailableMediaFoldersForLibrary(mediaFolder, config => config.IsVirtualFileSystemEnabled);
if (string.IsNullOrEmpty(vfsPath) || mediaConfigs.Count is 0)
return null;
@@ -139,6 +138,10 @@ private void OnLibraryManagerItemRemoved(object? sender, ItemChangeEventArgs e)
if (!Plugin.Instance.CanCreateSymbolicLinks)
throw new Exception("Windows users are required to enable Developer Mode then restart Jellyfin to be able to create symbolic links, a feature required to use the VFS.");
+ // Skip link generation if we've already generated for the library.
+ if (DataCache.TryGetValue($"should-skip-vfs-path:{vfsPath}", out var shouldReturnPath))
+ return shouldReturnPath ? vfsPath : null;
+
// Check full path and all parent directories if they have been indexed.
if (path.StartsWith(vfsPath + Path.DirectorySeparatorChar)) {
var pathSegments = path[(vfsPath.Length + 1)..].Split(Path.DirectorySeparatorChar).Prepend(vfsPath).ToArray();
@@ -154,7 +157,7 @@ private void OnLibraryManagerItemRemoved(object? sender, ItemChangeEventArgs e)
var key = mediaConfigs.Any(config => path.StartsWith(config.MediaFolderPath))
? $"should-skip-vfs-path:{vfsPath}"
: $"should-skip-vfs-path:{path}";
- var shouldReturnPath = await DataCache.GetOrCreateAsync(key, async (__) => {
+ shouldReturnPath = await DataCache.GetOrCreateAsync(key, async (__) => {
// Iterate the files already in the VFS.
string? pathToClean = null;
IEnumerable<(string sourceLocation, string fileId, string seriesId)>? allFiles = null;