1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-11-05 02:22:31 +01:00

Fixed: Include afpfs mount points in free space checks

Fixes #1399
This commit is contained in:
Mark McDowall 2016-07-26 22:40:54 -07:00
parent c3f9a0336c
commit e4adc1d3a1
7 changed files with 54 additions and 31 deletions

View File

@ -9,7 +9,6 @@
using NzbDrone.Common.EnvironmentInfo;
using NzbDrone.Common.Extensions;
using NzbDrone.Common.Instrumentation;
using NzbDrone.Common.Instrumentation.Extensions;
namespace NzbDrone.Common.Disk
{
@ -390,7 +389,10 @@ public FileStream OpenWriteStream(string path)
public virtual List<IMount> GetMounts()
{
return GetDriveInfoMounts();
return GetDriveInfoMounts().Where(d => d.DriveType == DriveType.Fixed || d.DriveType == DriveType.Network || d.DriveType == DriveType.Removable)
.Select(d => new DriveInfoMount(d))
.Cast<IMount>()
.ToList();
}
public virtual IMount GetMount(string path)
@ -411,13 +413,10 @@ public virtual IMount GetMount(string path)
}
}
protected List<IMount> GetDriveInfoMounts()
protected List<DriveInfo> GetDriveInfoMounts()
{
return DriveInfo.GetDrives()
.Where(d => d.DriveType == DriveType.Fixed || d.DriveType == DriveType.Network || d.DriveType == DriveType.Removable)
.Where(d => d.IsReady)
.Select(d => new DriveInfoMount(d))
.Cast<IMount>()
.ToList();
}

View File

@ -1,7 +1,4 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.IO;
using NzbDrone.Common.Extensions;
namespace NzbDrone.Common.Disk
@ -9,10 +6,12 @@ namespace NzbDrone.Common.Disk
public class DriveInfoMount : IMount
{
private readonly DriveInfo _driveInfo;
private readonly DriveType _driveType;
public DriveInfoMount(DriveInfo driveInfo)
public DriveInfoMount(DriveInfo driveInfo, DriveType driveType = DriveType.Unknown)
{
_driveInfo = driveInfo;
_driveType = driveType;
}
public long AvailableFreeSpace
@ -27,7 +26,15 @@ public string DriveFormat
public DriveType DriveType
{
get { return _driveInfo.DriveType; }
get
{
if (_driveType != DriveType.Unknown)
{
return _driveType;
}
return _driveInfo.DriveType;
}
}
public bool IsReady

View File

@ -86,7 +86,8 @@ public override void SetPermissions(string path, string mask, string user, strin
public override List<IMount> GetMounts()
{
return base.GetMounts()
return GetDriveInfoMounts().Select(d => new DriveInfoMount(d, FindDriveType.Find(d.DriveFormat)))
.Where(d => d.DriveType == DriveType.Fixed || d.DriveType == DriveType.Network || d.DriveType == DriveType.Removable)
.Concat(_procMountProvider.GetMounts())
.DistinctBy(v => v.RootDirectory)
.ToList();

View File

@ -0,0 +1,20 @@
using System.Collections.Generic;
using System.IO;
using NzbDrone.Common.Extensions;
namespace NzbDrone.Mono.Disk
{
public static class FindDriveType
{
private static readonly Dictionary<string, DriveType> DriveTypeMap = new Dictionary<string, DriveType>
{
{ "afpfs", DriveType.Network },
{ "zfs", DriveType.Fixed }
};
public static DriveType Find(string driveFormat)
{
return DriveTypeMap.GetValueOrDefault(driveFormat);
}
}
}

View File

@ -103,7 +103,7 @@ private IMount ParseLine(string line)
var type = split[2];
var options = ParseOptions(split[3]);
var driveType = DriveType.Unknown;
var driveType = FindDriveType.Find(type);
if (name.StartsWith("/dev/") || GetFileSystems().GetValueOrDefault(type, false))
{
@ -116,11 +116,6 @@ private IMount ParseLine(string line)
driveType = DriveType.Network;
}
if (type == "zfs")
{
driveType = DriveType.Fixed;
}
return new ProcMount(driveType, name, mount, type, options);
}

View File

@ -68,13 +68,14 @@
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="DiskProvider.cs" />
<Compile Include="LinuxPermissionsException.cs" />
<Compile Include="MonoRuntimeProvider.cs" />
<Compile Include="ProcMount.cs" />
<Compile Include="ProcMountProvider.cs" />
<Compile Include="Disk\DiskProvider.cs" />
<Compile Include="Disk\FindDriveType.cs" />
<Compile Include="Disk\LinuxPermissionsException.cs" />
<Compile Include="EnvironmentInfo\MonoRuntimeProvider.cs" />
<Compile Include="Disk\ProcMount.cs" />
<Compile Include="Disk\ProcMountProvider.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SymbolicLinkResolver.cs" />
<Compile Include="Disk\SymbolicLinkResolver.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\NzbDrone.Common\NzbDrone.Common.csproj">

View File

@ -63,8 +63,8 @@
<Reference Include="Microsoft.CSharp" />
</ItemGroup>
<ItemGroup>
<Compile Include="DiskProvider.cs" />
<Compile Include="DotNetRuntimeProvider.cs" />
<Compile Include="Disk\DiskProvider.cs" />
<Compile Include="EnvironmentInfo\DotNetRuntimeProvider.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>