From bd8fe03b49ece04f167f1fe234626ce4ba67b9dd Mon Sep 17 00:00:00 2001 From: Mikal Stordal Date: Sat, 24 Aug 2024 04:33:02 +0200 Subject: [PATCH] fix: attach VFS children to first available media folder - Attach VFS children to the first available media folder, instead of the first media folder in the list. If no media folders are available at all, then the VFS generation will be skipped (and Jellyfin will also internally skip the iteration of the children of the media folder if that were the case, so the shows/movies won't just disappear). --- Shokofin/Configuration/MediaFolderConfigurationService.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Shokofin/Configuration/MediaFolderConfigurationService.cs b/Shokofin/Configuration/MediaFolderConfigurationService.cs index af4da12f..d5987303 100644 --- a/Shokofin/Configuration/MediaFolderConfigurationService.cs +++ b/Shokofin/Configuration/MediaFolderConfigurationService.cs @@ -7,6 +7,7 @@ using Jellyfin.Data.Enums; using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Library; +using MediaBrowser.Controller.Providers; using MediaBrowser.Model.IO; using Microsoft.Extensions.Logging; using Shokofin.API; @@ -42,6 +43,8 @@ public class MediaFolderConfigurationService private readonly IFileSystem FileSystem; + private readonly IDirectoryService DirectoryService; + private readonly ShokoAPIClient ApiClient; private readonly NamingOptions NamingOptions; @@ -60,6 +63,7 @@ public MediaFolderConfigurationService( ILogger logger, ILibraryManager libraryManager, IFileSystem fileSystem, + IDirectoryService directoryService, ShokoAPIClient apiClient, NamingOptions namingOptions ) @@ -67,6 +71,7 @@ NamingOptions namingOptions Logger = logger; LibraryManager = libraryManager; FileSystem = fileSystem; + DirectoryService = directoryService; ApiClient = apiClient; NamingOptions = namingOptions; @@ -161,7 +166,7 @@ private void OnLibraryManagerItemRemoved(object? sender, ItemChangeEventArgs e) return (string.Empty, string.Empty, null, new List()); return ( libraryFolder.GetVirtualRoot(), - virtualFolder.Locations[0], + virtualFolder.Locations.FirstOrDefault(a => DirectoryService.IsAccessible(a)) ?? string.Empty, LibraryManager.GetConfiguredContentType(libraryFolder), Plugin.Instance.Configuration.MediaFolders .Where(config => config.IsMapped && config.LibraryId == mediaFolderConfig.LibraryId && (filter is null || filter(config)) && LibraryManager.GetItemById(config.MediaFolderId) is Folder)