Skip to content

Commit

Permalink
fix: attach VFS children to first available media folder
Browse files Browse the repository at this point in the history
- 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).
  • Loading branch information
revam committed Aug 24, 2024
1 parent 6700b77 commit bd8fe03
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 @@ -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;
Expand Down Expand Up @@ -42,6 +43,8 @@ public class MediaFolderConfigurationService

private readonly IFileSystem FileSystem;

private readonly IDirectoryService DirectoryService;

private readonly ShokoAPIClient ApiClient;

private readonly NamingOptions NamingOptions;
Expand All @@ -60,13 +63,15 @@ public MediaFolderConfigurationService(
ILogger<MediaFolderConfigurationService> logger,
ILibraryManager libraryManager,
IFileSystem fileSystem,
IDirectoryService directoryService,
ShokoAPIClient apiClient,
NamingOptions namingOptions
)
{
Logger = logger;
LibraryManager = libraryManager;
FileSystem = fileSystem;
DirectoryService = directoryService;
ApiClient = apiClient;
NamingOptions = namingOptions;

Expand Down Expand Up @@ -161,7 +166,7 @@ private void OnLibraryManagerItemRemoved(object? sender, ItemChangeEventArgs e)
return (string.Empty, string.Empty, null, new List<MediaFolderConfiguration>());
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)
Expand Down

0 comments on commit bd8fe03

Please sign in to comment.