1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-12-16 11:37:58 +02:00

Free disk space check on Linux will use best match

Fixed: Better disk space check on Linux
This commit is contained in:
Mark McDowall 2013-11-07 17:46:07 -08:00
parent 2183526a34
commit 5c2073b297

View File

@ -303,25 +303,23 @@ public void InheritFolderPermissions(string filename)
{ {
var drives = DriveInfo.GetDrives(); var drives = DriveInfo.GetDrives();
foreach (var drive in drives) try
{ {
try return
{ drives.Where(drive =>
if (drive.IsReady && path.StartsWith(drive.Name, StringComparison.CurrentCultureIgnoreCase)) drive.IsReady && path.StartsWith(drive.Name, StringComparison.CurrentCultureIgnoreCase))
{ .OrderByDescending(drive => drive.Name.Length)
return drive.AvailableFreeSpace; .First()
} .AvailableFreeSpace;
} }
catch (InvalidOperationException e) catch (InvalidOperationException e)
{ {
Logger.ErrorException("Couldn't get free space for " + path, e); Logger.ErrorException("Couldn't get free space for " + path, e);
}
} }
return null; return null;
} }
return DriveFreeSpaceEx(root); return DriveFreeSpaceEx(root);
} }