1
0
Fork 0
mirror of https://github.com/Sonarr/Sonarr synced 2024-12-21 23:33:00 +00:00

Fixed: Don't fail import if symlink target can't be resolved

Closes #7431
This commit is contained in:
Mark McDowall 2024-12-01 08:59:44 -08:00
parent 4c41a4f368
commit 8cb58a63d8

View file

@ -190,16 +190,23 @@ 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))
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;
}