diff options
| author | Bond-009 <bond.009@outlook.com> | 2021-04-10 23:18:55 +0200 |
|---|---|---|
| committer | Joshua M. Boniface <joshua@boniface.me> | 2021-04-11 14:13:44 -0400 |
| commit | f77673438e3d90050783a338c193be9da7fc0e73 (patch) | |
| tree | 6edf3d7b9b21e598e7a5b8c7d6a7bd6f40ec929d | |
| parent | bc2eb9fa7914226f72cfa577f452c2ecb0dfbf26 (diff) | |
Merge pull request #5746 from cvium/dangling-symlinks
(cherry picked from commit 62117a6c125f2f35ca3c9d7507f3464482caa7f1)
Signed-off-by: Joshua M. Boniface <joshua@boniface.me>
| -rw-r--r-- | Emby.Server.Implementations/IO/ManagedFileSystem.cs | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/Emby.Server.Implementations/IO/ManagedFileSystem.cs b/Emby.Server.Implementations/IO/ManagedFileSystem.cs index c0e757543..d6ccd44be 100644 --- a/Emby.Server.Implementations/IO/ManagedFileSystem.cs +++ b/Emby.Server.Implementations/IO/ManagedFileSystem.cs @@ -249,9 +249,18 @@ namespace Emby.Server.Implementations.IO // Issue #2354 get the size of files behind symbolic links if (fileInfo.Attributes.HasFlag(FileAttributes.ReparsePoint)) { - using (Stream thisFileStream = File.OpenRead(fileInfo.FullName)) + try { - result.Length = thisFileStream.Length; + using (Stream thisFileStream = File.OpenRead(fileInfo.FullName)) + { + result.Length = thisFileStream.Length; + } + } + catch (FileNotFoundException ex) + { + // Dangling symlinks cannot be detected before opening the file unfortunately... + Logger.LogError(ex, "Reading the file size of the symlink at {Path} failed. Marking the file as not existing.", fileInfo.FullName); + result.Exists = false; } } |
