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,10 +86,11 @@ 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)))
|
||||||
.Concat(_procMountProvider.GetMounts())
|
.Where(d => d.DriveType == DriveType.Fixed || d.DriveType == DriveType.Network || d.DriveType == DriveType.Removable)
|
||||||
.DistinctBy(v => v.RootDirectory)
|
.Concat(_procMountProvider.GetMounts())
|
||||||
.ToList();
|
.DistinctBy(v => v.RootDirectory)
|
||||||
|
.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override long? GetTotalSize(string path)
|
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 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))
|
||||||
{
|
{
|
||||||
// Not always fixed, but lets assume it.
|
// Not always fixed, but lets assume it.
|
||||||
|
@ -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…
Reference in New Issue