diff options
| author | Joshua M. Boniface <joshua@boniface.me> | 2026-03-23 23:09:56 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-03-23 23:09:56 -0400 |
| commit | 965b602c6890623130d1d7e27de52e161c6d1069 (patch) | |
| tree | 681abbf43895e8e89199347cbf02d6f37ab80b5f | |
| parent | 8142bbd50e4c2218e99c621900430b0189c267c3 (diff) | |
Apply suggestions from code review
Co-authored-by: JPVenson <ger-delta-07@hotmail.de>
| -rw-r--r-- | Jellyfin.Server.Implementations/StorageHelpers/StorageHelper.cs | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/Jellyfin.Server.Implementations/StorageHelpers/StorageHelper.cs b/Jellyfin.Server.Implementations/StorageHelpers/StorageHelper.cs index b80d65ecbe..d3f94ad0bd 100644 --- a/Jellyfin.Server.Implementations/StorageHelpers/StorageHelper.cs +++ b/Jellyfin.Server.Implementations/StorageHelpers/StorageHelper.cs @@ -37,24 +37,26 @@ public static class StorageHelper try { // Fully resolve the given path to an actual filesystem target, in case it's a symlink or similar. - string resolvedPath = ResolvePath(path); + var resolvedPath = ResolvePath(path); // We iterate all filesystems reported by GetDrives() here, and attempt to find the best // match that contains, as deep as possible, the given path. // This is required because simply calling `DriveInfo` on a path returns that path as // the Name and RootDevice, which is not at all how this should work. - DriveInfo[] allDrives = DriveInfo.GetDrives(); - DriveInfo bestMatch = null; + var allDrives = DriveInfo.GetDrives(); + DriveInfo? bestMatch = null; foreach (DriveInfo d in allDrives) { - if (resolvedPath.StartsWith(d.RootDirectory.FullName) && - (bestMatch == null || d.RootDirectory.FullName.Length > bestMatch.RootDirectory.FullName.Length)) + if (resolvedPath.StartsWith(d.RootDirectory.FullName, StringComparison.InvariantCultureIgnoreCase) && + (bestMatch is null || d.RootDirectory.FullName.Length > bestMatch.RootDirectory.FullName.Length)) { bestMatch = d; } } + if (bestMatch is null) { throw new InvalidOperationException($"The path `{path}` has no matching parent device. Space check invalid."); } + return new FolderStorageInfo() { Path = path, |
