From 2429dd91c6d08eb2b70b14db2b3c673d320e6a5c Mon Sep 17 00:00:00 2001 From: Elias Benbourenane Date: Thu, 14 Nov 2024 22:27:56 -0500 Subject: [PATCH] Allow `GetFileSize` to follow symlinks (cherry picked from commit ca0bb14027f3409014e7cf9ffa8e04e577001d77) --- src/NzbDrone.Common/Disk/DiskProviderBase.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/NzbDrone.Common/Disk/DiskProviderBase.cs b/src/NzbDrone.Common/Disk/DiskProviderBase.cs index 20a6607ac..8983b9298 100644 --- a/src/NzbDrone.Common/Disk/DiskProviderBase.cs +++ b/src/NzbDrone.Common/Disk/DiskProviderBase.cs @@ -189,6 +189,18 @@ namespace NzbDrone.Common.Disk } var fi = new FileInfo(path); + + // If the file is a symlink, resolve the target path and get the size of the target file. + if (fi.Attributes.HasFlag(FileAttributes.ReparsePoint)) + { + var targetPath = fi.ResolveLinkTarget(true)?.FullName; + + if (targetPath != null) + { + fi = new FileInfo(targetPath); + } + } + return fi.Length; }