mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-04-09 11:52:07 +01:00
Resolve symlinks for static media source infos (#15263)
This commit is contained in:
@@ -24,6 +24,7 @@ using MediaBrowser.Controller.Configuration;
|
||||
using MediaBrowser.Controller.Dto;
|
||||
using MediaBrowser.Controller.Entities.Audio;
|
||||
using MediaBrowser.Controller.Entities.TV;
|
||||
using MediaBrowser.Controller.IO;
|
||||
using MediaBrowser.Controller.Library;
|
||||
using MediaBrowser.Controller.MediaSegments;
|
||||
using MediaBrowser.Controller.Persistence;
|
||||
@@ -1127,6 +1128,15 @@ namespace MediaBrowser.Controller.Entities
|
||||
|
||||
var protocol = item.PathProtocol;
|
||||
|
||||
// Resolve the item path so everywhere we use the media source it will always point to
|
||||
// the correct path even if symlinks are in use. Calling ResolveLinkTarget on a non-link
|
||||
// path will return null, so it's safe to check for all paths.
|
||||
var itemPath = item.Path;
|
||||
if (protocol is MediaProtocol.File && FileSystemHelper.ResolveLinkTarget(itemPath, returnFinalTarget: true) is { Exists: true } linkInfo)
|
||||
{
|
||||
itemPath = linkInfo.FullName;
|
||||
}
|
||||
|
||||
var info = new MediaSourceInfo
|
||||
{
|
||||
Id = item.Id.ToString("N", CultureInfo.InvariantCulture),
|
||||
@@ -1134,7 +1144,7 @@ namespace MediaBrowser.Controller.Entities
|
||||
MediaStreams = MediaSourceManager.GetMediaStreams(item.Id),
|
||||
MediaAttachments = MediaSourceManager.GetMediaAttachments(item.Id),
|
||||
Name = GetMediaSourceName(item),
|
||||
Path = enablePathSubstitution ? GetMappedPath(item, item.Path, protocol) : item.Path,
|
||||
Path = enablePathSubstitution ? GetMappedPath(item, itemPath, protocol) : itemPath,
|
||||
RunTimeTicks = item.RunTimeTicks,
|
||||
Container = item.Container,
|
||||
Size = item.Size,
|
||||
|
||||
Reference in New Issue
Block a user