mirror of
https://github.com/jellyfin/jellyfin
synced 2024-10-01 13:34:26 +00:00
Allow absolute path mismatch when getting virtual folder info
We have historically required the path stored in the database to exactly match the actual path on the filesystem to retrieve virtual folder information, dating back to the Emby era. However, this approach can cause issues when symbolic links are involved, as the link path may differ from the actual pointed path. To address this, allow matching based solely on the folder name when absolute path checking fails, mitigating such problems. Signed-off-by: gnattu <gnattuoc@me.com>
This commit is contained in:
parent
44b03a3315
commit
a0117c5eea
|
@ -1152,11 +1152,11 @@ namespace Emby.Server.Implementations.Library
|
||||||
var refreshQueue = includeRefreshState ? ProviderManager.GetRefreshQueue() : null;
|
var refreshQueue = includeRefreshState ? ProviderManager.GetRefreshQueue() : null;
|
||||||
|
|
||||||
return _fileSystem.GetDirectoryPaths(_configurationManager.ApplicationPaths.DefaultUserViewsPath)
|
return _fileSystem.GetDirectoryPaths(_configurationManager.ApplicationPaths.DefaultUserViewsPath)
|
||||||
.Select(dir => GetVirtualFolderInfo(dir, topLibraryFolders, refreshQueue))
|
.Select(dir => GetVirtualFolderInfo(dir, topLibraryFolders, refreshQueue, true))
|
||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
private VirtualFolderInfo GetVirtualFolderInfo(string dir, List<BaseItem> allCollectionFolders, HashSet<Guid>? refreshQueue)
|
private VirtualFolderInfo GetVirtualFolderInfo(string dir, List<BaseItem> allCollectionFolders, HashSet<Guid>? refreshQueue, bool allowAbsolutePathMismatch = false)
|
||||||
{
|
{
|
||||||
var info = new VirtualFolderInfo
|
var info = new VirtualFolderInfo
|
||||||
{
|
{
|
||||||
|
@ -1184,6 +1184,12 @@ namespace Emby.Server.Implementations.Library
|
||||||
};
|
};
|
||||||
|
|
||||||
var libraryFolder = allCollectionFolders.FirstOrDefault(i => string.Equals(i.Path, dir, StringComparison.OrdinalIgnoreCase));
|
var libraryFolder = allCollectionFolders.FirstOrDefault(i => string.Equals(i.Path, dir, StringComparison.OrdinalIgnoreCase));
|
||||||
|
if (libraryFolder is null && allowAbsolutePathMismatch)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Absolute path does not match any virtual folder, guessing from folder name");
|
||||||
|
libraryFolder = allCollectionFolders.FirstOrDefault(i => string.Equals(Path.GetDirectoryName(i.Path), Path.GetDirectoryName(dir), StringComparison.OrdinalIgnoreCase));
|
||||||
|
}
|
||||||
|
|
||||||
if (libraryFolder is not null)
|
if (libraryFolder is not null)
|
||||||
{
|
{
|
||||||
var libraryFolderId = libraryFolder.Id.ToString("N", CultureInfo.InvariantCulture);
|
var libraryFolderId = libraryFolder.Id.ToString("N", CultureInfo.InvariantCulture);
|
||||||
|
|
Loading…
Reference in a new issue