From 22d593b8e986ecdb42fb1e618bfcf833b0a6f118 Mon Sep 17 00:00:00 2001
From: Collin T Swisher <79892877+Collin-Swish@users.noreply.github.com>
Date: Fri, 16 Jan 2026 19:47:04 -0600
Subject: [PATCH] Add mblink creation logic to library update endpoint.
(#15965)
---
.../Library/LibraryManager.cs | 33 +++++++++++--------
.../Controllers/LibraryStructureController.cs | 11 +++++++
.../Library/ILibraryManager.cs | 7 ++++
3 files changed, 38 insertions(+), 13 deletions(-)
diff --git a/Emby.Server.Implementations/Library/LibraryManager.cs b/Emby.Server.Implementations/Library/LibraryManager.cs
index 1716c49e59..aa5b37a94d 100644
--- a/Emby.Server.Implementations/Library/LibraryManager.cs
+++ b/Emby.Server.Implementations/Library/LibraryManager.cs
@@ -3201,19 +3201,7 @@ namespace Emby.Server.Implementations.Library
var rootFolderPath = _configurationManager.ApplicationPaths.DefaultUserViewsPath;
var virtualFolderPath = Path.Combine(rootFolderPath, virtualFolderName);
- var shortcutFilename = Path.GetFileNameWithoutExtension(path);
-
- var lnk = Path.Combine(virtualFolderPath, shortcutFilename + ShortcutFileExtension);
-
- while (File.Exists(lnk))
- {
- shortcutFilename += "1";
- lnk = Path.Combine(virtualFolderPath, shortcutFilename + ShortcutFileExtension);
- }
-
- _fileSystem.CreateShortcut(lnk, _appHost.ReverseVirtualPath(path));
-
- RemoveContentTypeOverrides(path);
+ CreateShortcut(virtualFolderPath, pathInfo);
if (saveLibraryOptions)
{
@@ -3378,5 +3366,24 @@ namespace Emby.Server.Implementations.Library
return item is UserRootFolder || item.IsVisibleStandalone(user);
}
+
+ public void CreateShortcut(string virtualFolderPath, MediaPathInfo pathInfo)
+ {
+ var path = pathInfo.Path;
+ var rootFolderPath = _configurationManager.ApplicationPaths.DefaultUserViewsPath;
+
+ var shortcutFilename = Path.GetFileNameWithoutExtension(path);
+
+ var lnk = Path.Combine(virtualFolderPath, shortcutFilename + ShortcutFileExtension);
+
+ while (File.Exists(lnk))
+ {
+ shortcutFilename += "1";
+ lnk = Path.Combine(virtualFolderPath, shortcutFilename + ShortcutFileExtension);
+ }
+
+ _fileSystem.CreateShortcut(lnk, _appHost.ReverseVirtualPath(path));
+ RemoveContentTypeOverrides(path);
+ }
}
}
diff --git a/Jellyfin.Api/Controllers/LibraryStructureController.cs b/Jellyfin.Api/Controllers/LibraryStructureController.cs
index 2a885662b5..117811429a 100644
--- a/Jellyfin.Api/Controllers/LibraryStructureController.cs
+++ b/Jellyfin.Api/Controllers/LibraryStructureController.cs
@@ -342,6 +342,17 @@ public class LibraryStructureController : BaseJellyfinApiController
return NotFound();
}
+ LibraryOptions options = item.GetLibraryOptions();
+ foreach (var mediaPath in request.LibraryOptions!.PathInfos)
+ {
+ if (options.PathInfos.Any(i => i.Path == mediaPath.Path))
+ {
+ continue;
+ }
+
+ _libraryManager.CreateShortcut(item.Path, mediaPath);
+ }
+
item.UpdateLibraryOptions(request.LibraryOptions);
return NoContent();
}
diff --git a/MediaBrowser.Controller/Library/ILibraryManager.cs b/MediaBrowser.Controller/Library/ILibraryManager.cs
index 675812ac23..df1c98f3f7 100644
--- a/MediaBrowser.Controller/Library/ILibraryManager.cs
+++ b/MediaBrowser.Controller/Library/ILibraryManager.cs
@@ -660,5 +660,12 @@ namespace MediaBrowser.Controller.Library
/// This exists so plugins can trigger a library scan.
///
void QueueLibraryScan();
+
+ ///
+ /// Add mblink file for a media path.
+ ///
+ /// The path to the virtualfolder.
+ /// The new virtualfolder.
+ public void CreateShortcut(string virtualFolderPath, MediaPathInfo pathInfo);
}
}