From 8cb58a63d8ec1b290bc57ad2cf1e90809ceebce9 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Sun, 1 Dec 2024 08:59:44 -0800 Subject: [PATCH] Fixed: Don't fail import if symlink target can't be resolved Closes #7431 --- src/NzbDrone.Common/Disk/DiskProviderBase.cs | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/NzbDrone.Common/Disk/DiskProviderBase.cs b/src/NzbDrone.Common/Disk/DiskProviderBase.cs index 07b6775cb..6fcfa94b0 100644 --- a/src/NzbDrone.Common/Disk/DiskProviderBase.cs +++ b/src/NzbDrone.Common/Disk/DiskProviderBase.cs @@ -190,16 +190,23 @@ public long GetFileSize(string path) 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)) + try { - var targetPath = fi.ResolveLinkTarget(true)?.FullName; - - if (targetPath != null) + // If the file is a symlink, resolve the target path and get the size of the target file. + if (fi.Attributes.HasFlag(FileAttributes.ReparsePoint)) { - fi = new FileInfo(targetPath); + var targetPath = fi.ResolveLinkTarget(true)?.FullName; + + if (targetPath != null) + { + fi = new FileInfo(targetPath); + } } } + catch (IOException ex) + { + Logger.Trace(ex, "Unable to resolve symlink target for {0}", path); + } return fi.Length; }