mirror of
https://github.com/Radarr/Radarr.git
synced 2024-09-17 15:02:34 +02:00
Fixed: USB drives mounted to folders are treated as different mounts
(cherry picked from commit 75378f7bde90b9d3d9b72404c25c017da2cd147c)
This commit is contained in:
parent
a78693a2f7
commit
189603c756
@ -356,7 +356,7 @@ public bool IsFileLocked(string file)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GetPathRoot(string path)
|
public virtual string GetPathRoot(string path)
|
||||||
{
|
{
|
||||||
Ensure.That(path, () => path).IsValidPath();
|
Ensure.That(path, () => path).IsValidPath();
|
||||||
|
|
||||||
|
@ -26,6 +26,22 @@ private static extern bool GetDiskFreeSpaceEx(string lpDirectoryName,
|
|||||||
[return: MarshalAs(UnmanagedType.Bool)]
|
[return: MarshalAs(UnmanagedType.Bool)]
|
||||||
private static extern bool CreateHardLink(string lpFileName, string lpExistingFileName, IntPtr lpSecurityAttributes);
|
private static extern bool CreateHardLink(string lpFileName, string lpExistingFileName, IntPtr lpSecurityAttributes);
|
||||||
|
|
||||||
|
public override IMount GetMount(string path)
|
||||||
|
{
|
||||||
|
var reparsePoint = GetReparsePoint(path);
|
||||||
|
|
||||||
|
return reparsePoint ?? base.GetMount(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override string GetPathRoot(string path)
|
||||||
|
{
|
||||||
|
Ensure.That(path, () => path).IsValidPath();
|
||||||
|
|
||||||
|
var reparsePoint = GetReparsePoint(path);
|
||||||
|
|
||||||
|
return reparsePoint?.RootDirectory ?? base.GetPathRoot(path);
|
||||||
|
}
|
||||||
|
|
||||||
public override long? GetAvailableSpace(string path)
|
public override long? GetAvailableSpace(string path)
|
||||||
{
|
{
|
||||||
Ensure.That(path, () => path).IsValidPath();
|
Ensure.That(path, () => path).IsValidPath();
|
||||||
@ -171,5 +187,23 @@ public override bool TryCreateHardLink(string source, string destination)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private IMount GetReparsePoint(string path)
|
||||||
|
{
|
||||||
|
var di = new DirectoryInfo(path);
|
||||||
|
var isReparsePoint = di.Attributes.HasFlag(FileAttributes.ReparsePoint);
|
||||||
|
|
||||||
|
while (!isReparsePoint && (di = di.Parent) != null)
|
||||||
|
{
|
||||||
|
isReparsePoint = di.Attributes.HasFlag(FileAttributes.ReparsePoint);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isReparsePoint)
|
||||||
|
{
|
||||||
|
return new FolderMount(di);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
38
src/NzbDrone.Windows/Disk/FolderMount.cs
Normal file
38
src/NzbDrone.Windows/Disk/FolderMount.cs
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
using System.IO;
|
||||||
|
using NzbDrone.Common.Disk;
|
||||||
|
using NzbDrone.Common.Extensions;
|
||||||
|
|
||||||
|
namespace NzbDrone.Windows.Disk
|
||||||
|
{
|
||||||
|
public class FolderMount : IMount
|
||||||
|
{
|
||||||
|
private readonly DirectoryInfo _directoryInfo;
|
||||||
|
|
||||||
|
public FolderMount(DirectoryInfo directoryInfo)
|
||||||
|
{
|
||||||
|
_directoryInfo = directoryInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long AvailableFreeSpace => 0;
|
||||||
|
|
||||||
|
public string DriveFormat => "NTFS";
|
||||||
|
|
||||||
|
public DriveType DriveType => DriveType.Removable;
|
||||||
|
|
||||||
|
public bool IsReady => true;
|
||||||
|
|
||||||
|
public MountOptions MountOptions { get; private set; }
|
||||||
|
|
||||||
|
public string Name => _directoryInfo.Name;
|
||||||
|
|
||||||
|
public string RootDirectory => _directoryInfo.FullName;
|
||||||
|
|
||||||
|
public long TotalFreeSpace => 0;
|
||||||
|
|
||||||
|
public long TotalSize => 0;
|
||||||
|
|
||||||
|
public string VolumeLabel => _directoryInfo.Name;
|
||||||
|
|
||||||
|
public string VolumeName => Name;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user