mirror of
https://github.com/lidarr/Lidarr
synced 2025-01-03 13:34:54 +00:00
Fixed: Total free space on Linux
This commit is contained in:
parent
018b898a46
commit
9fcd422f29
1 changed files with 18 additions and 23 deletions
|
@ -301,16 +301,9 @@ public void InheritFolderPermissions(string filename)
|
|||
|
||||
if (OsInfo.IsLinux)
|
||||
{
|
||||
var drives = DriveInfo.GetDrives();
|
||||
|
||||
try
|
||||
{
|
||||
return
|
||||
drives.Where(drive =>
|
||||
drive.IsReady && path.StartsWith(drive.Name, StringComparison.CurrentCultureIgnoreCase))
|
||||
.OrderByDescending(drive => drive.Name.Length)
|
||||
.First()
|
||||
.AvailableFreeSpace;
|
||||
return GetDriveInfoLinux(path).AvailableFreeSpace;
|
||||
}
|
||||
catch (InvalidOperationException e)
|
||||
{
|
||||
|
@ -469,27 +462,18 @@ public string[] GetFixedDrives()
|
|||
|
||||
if (OsInfo.IsLinux)
|
||||
{
|
||||
var drives = DriveInfo.GetDrives();
|
||||
|
||||
foreach (var drive in drives)
|
||||
try
|
||||
{
|
||||
try
|
||||
{
|
||||
if (drive.IsReady && path.StartsWith(drive.Name, StringComparison.CurrentCultureIgnoreCase))
|
||||
{
|
||||
return drive.TotalSize;
|
||||
}
|
||||
}
|
||||
catch (InvalidOperationException e)
|
||||
{
|
||||
Logger.ErrorException("Couldn't get total space for " + path, e);
|
||||
}
|
||||
return GetDriveInfoLinux(path).TotalFreeSpace;
|
||||
}
|
||||
catch (InvalidOperationException e)
|
||||
{
|
||||
Logger.ErrorException("Couldn't get total space for " + path, e);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
return DriveTotalSizeEx(root);
|
||||
}
|
||||
|
||||
|
@ -552,5 +536,16 @@ private static long DriveTotalSizeEx(string folderName)
|
|||
|
||||
return 0;
|
||||
}
|
||||
|
||||
private DriveInfo GetDriveInfoLinux(string path)
|
||||
{
|
||||
var drives = DriveInfo.GetDrives();
|
||||
|
||||
return
|
||||
drives.Where(drive =>
|
||||
drive.IsReady && path.StartsWith(drive.Name, StringComparison.CurrentCultureIgnoreCase))
|
||||
.OrderByDescending(drive => drive.Name.Length)
|
||||
.First();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue