mirror of
https://github.com/Radarr/Radarr
synced 2026-05-09 01:03:43 +02:00
Allow GetFileSize to follow symlinks
(cherry picked from commit ca0bb14027f3409014e7cf9ffa8e04e577001d77)
This commit is contained in:
parent
a752476cdb
commit
2429dd91c6
1 changed files with 12 additions and 0 deletions
|
|
@ -189,6 +189,18 @@ public long GetFileSize(string path)
|
||||||
}
|
}
|
||||||
|
|
||||||
var fi = new FileInfo(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))
|
||||||
|
{
|
||||||
|
var targetPath = fi.ResolveLinkTarget(true)?.FullName;
|
||||||
|
|
||||||
|
if (targetPath != null)
|
||||||
|
{
|
||||||
|
fi = new FileInfo(targetPath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return fi.Length;
|
return fi.Length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue