New: Fast copy using reflink on btrfs volumes

This commit is contained in:
Taloth Saldono
2020-06-10 20:48:54 +02:00
committed by Qstick
parent 67d2765d0c
commit 38855967d6
7 changed files with 224 additions and 1 deletions
@@ -198,6 +198,24 @@ namespace NzbDrone.Common.Disk
File.Delete(path);
}
public void CloneFile(string source, string destination, bool overwrite = false)
{
Ensure.That(source, () => source).IsValidPath();
Ensure.That(destination, () => destination).IsValidPath();
if (source.PathEquals(destination))
{
throw new IOException(string.Format("Source and destination can't be the same {0}", source));
}
CloneFileInternal(source, destination, overwrite);
}
protected virtual void CloneFileInternal(string source, string destination, bool overwrite = false)
{
CopyFileInternal(source, destination, overwrite);
}
public void CopyFile(string source, string destination, bool overwrite = false)
{
Ensure.That(source, () => source).IsValidPath();
@@ -259,8 +277,18 @@ namespace NzbDrone.Common.Disk
File.Move(source, destination);
}
public virtual bool TryRenameFile(string source, string destination)
{
return false;
}
public abstract bool TryCreateHardLink(string source, string destination);
public virtual bool TryCreateRefLink(string source, string destination)
{
return false;
}
public void DeleteFolder(string path, bool recursive)
{
Ensure.That(path, () => path).IsValidPath();