mirror of
https://github.com/Sonarr/Sonarr.git
synced 2024-11-21 17:56:43 +02:00
Allow GetFileSize
to follow symlinks
This commit is contained in:
parent
3e99917e9d
commit
ca0bb14027
@ -189,6 +189,18 @@ 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))
|
||||
{
|
||||
var targetPath = fi.ResolveLinkTarget(true)?.FullName;
|
||||
|
||||
if (targetPath != null)
|
||||
{
|
||||
fi = new FileInfo(targetPath);
|
||||
}
|
||||
}
|
||||
|
||||
return fi.Length;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user