Skip to content

Commit

Permalink
fix: fix regression for link generation
Browse files Browse the repository at this point in the history
- Add back the check for if the VFS has already been generated for the ~~media folder~~ library.
  • Loading branch information
revam committed Jun 24, 2024
1 parent 54862f5 commit 552a39e
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions Shokofin/Resolvers/VirtualFileSystemService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -131,14 +131,17 @@ private void OnLibraryManagerItemRemoved(object? sender, ItemChangeEventArgs e)
/// <returns>The VFS path, if it succeeded.</returns>
public async Task<string?> 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;

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<bool>($"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();
Expand All @@ -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<bool>(key, async (__) => {
shouldReturnPath = await DataCache.GetOrCreateAsync<bool>(key, async (__) => {
// Iterate the files already in the VFS.
string? pathToClean = null;
IEnumerable<(string sourceLocation, string fileId, string seriesId)>? allFiles = null;
Expand Down

0 comments on commit 552a39e

Please sign in to comment.