diff options
| author | ivanjx <ivanjx@users.noreply.github.com> | 2025-12-28 07:22:15 -0500 |
|---|---|---|
| committer | Bond_009 <bond.009@outlook.com> | 2025-12-28 07:22:15 -0500 |
| commit | 5d50ff5f81872cc9c2b1611c878162a39714a1a8 (patch) | |
| tree | 66249323de66dae996cb37130c09c7cb5f62cf4f /Jellyfin.Api/Controllers/LibraryController.cs | |
| parent | 8e2ed40a8bf309c76a2e3b468d606392554cfe8b (diff) | |
Backport pull request #15681 from jellyfin/release-10.11.z
Fix symlinked file size
Original-merge: d32f487e8e4762bba740b586285b663712eda69a
Merged-by: crobibero <cody@robibe.ro>
Backported-by: Bond_009 <bond.009@outlook.com>
Diffstat (limited to 'Jellyfin.Api/Controllers/LibraryController.cs')
| -rw-r--r-- | Jellyfin.Api/Controllers/LibraryController.cs | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/Jellyfin.Api/Controllers/LibraryController.cs b/Jellyfin.Api/Controllers/LibraryController.cs index 4e898c00e..558e1c6c8 100644 --- a/Jellyfin.Api/Controllers/LibraryController.cs +++ b/Jellyfin.Api/Controllers/LibraryController.cs @@ -23,6 +23,7 @@ using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities.Audio; using MediaBrowser.Controller.Entities.Movies; using MediaBrowser.Controller.Entities.TV; +using MediaBrowser.Controller.IO; using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Providers; using MediaBrowser.Model.Activity; @@ -700,7 +701,18 @@ public class LibraryController : BaseJellyfinApiController // Quotes are valid in linux. They'll possibly cause issues here. var filename = Path.GetFileName(item.Path)?.Replace("\"", string.Empty, StringComparison.Ordinal); - return PhysicalFile(item.Path, MimeTypes.GetMimeType(item.Path), filename, true); + var filePath = item.Path; + if (item.IsFileProtocol) + { + // PhysicalFile does not work well with symlinks at the moment. + var resolved = FileSystemHelper.ResolveLinkTarget(filePath, returnFinalTarget: true); + if (resolved is not null && resolved.Exists) + { + filePath = resolved.FullName; + } + } + + return PhysicalFile(filePath, MimeTypes.GetMimeType(filePath), filename, true); } /// <summary> |
