Fixed: Include afpfs mount points in free space checks

Fixes #1399
pull/1402/merge
Mark McDowall 8 years ago
parent c3f9a0336c
commit e4adc1d3a1

@ -9,7 +9,6 @@ using NzbDrone.Common.EnsureThat;
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 @@ namespace NzbDrone.Common.Disk
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 @@ namespace NzbDrone.Common.Disk
}
}
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();
}

@ -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 @@ namespace NzbDrone.Common.Disk
public DriveType DriveType
{
get { return _driveInfo.DriveType; }
get
{
if (_driveType != DriveType.Unknown)
{
return _driveType;
}
return _driveInfo.DriveType;
}
}
public bool IsReady

@ -86,10 +86,11 @@ namespace NzbDrone.Mono.Disk
public override List<IMount> GetMounts()
{
return base.GetMounts()
.Concat(_procMountProvider.GetMounts())
.DistinctBy(v => v.RootDirectory)
.ToList();
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();
}
public override long? GetTotalSize(string path)

@ -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,8 +103,8 @@ namespace NzbDrone.Mono.Disk
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))
{
// Not always fixed, but lets assume it.
@ -116,11 +116,6 @@ namespace NzbDrone.Mono.Disk
driveType = DriveType.Network;
}
if (type == "zfs")
{
driveType = DriveType.Fixed;
}
return new ProcMount(driveType, name, mount, type, options);
}

@ -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">

@ -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>

Loading…
Cancel
Save