Fixed: Include afpfs mount points in free space checks

Fixes #1399
pull/3113/head
Mark McDowall 8 years ago
parent c3f9a0336c
commit e4adc1d3a1

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

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

@ -86,7 +86,8 @@ namespace NzbDrone.Mono.Disk
public override List<IMount> GetMounts() 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()) .Concat(_procMountProvider.GetMounts())
.DistinctBy(v => v.RootDirectory) .DistinctBy(v => v.RootDirectory)
.ToList(); .ToList();

@ -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);
}
}
}

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

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

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

Loading…
Cancel
Save