mirror of
https://github.com/Readarr/Readarr.git
synced 2026-04-26 22:46:37 -04:00
New: Fast copy using reflink on btrfs volumes
Signed-off-by: Robin Dadswell <robin@dadswell.email>
This commit is contained in:
@@ -284,18 +284,45 @@ namespace NzbDrone.Common.Disk
|
||||
var targetDriveFormat = targetMount?.DriveFormat ?? string.Empty;
|
||||
|
||||
var isCifs = targetDriveFormat == "cifs";
|
||||
var isBtrfs = sourceDriveFormat == "btrfs" && targetDriveFormat == "btrfs";
|
||||
|
||||
if (mode.HasFlag(TransferMode.Copy))
|
||||
{
|
||||
if (isBtrfs)
|
||||
{
|
||||
if (_diskProvider.TryCreateRefLink(sourcePath, targetPath))
|
||||
{
|
||||
return TransferMode.Copy;
|
||||
}
|
||||
}
|
||||
|
||||
TryCopyFileVerified(sourcePath, targetPath, originalSize);
|
||||
return TransferMode.Copy;
|
||||
}
|
||||
|
||||
if (mode.HasFlag(TransferMode.Move))
|
||||
{
|
||||
if (isBtrfs)
|
||||
{
|
||||
if (isSameMount && _diskProvider.TryRenameFile(sourcePath, targetPath))
|
||||
{
|
||||
_logger.Trace("Renamed [{0}] to [{1}].", sourcePath, targetPath);
|
||||
return TransferMode.Move;
|
||||
}
|
||||
|
||||
if (_diskProvider.TryCreateRefLink(sourcePath, targetPath))
|
||||
{
|
||||
_logger.Trace("Reflink successful, deleting source [{0}].", sourcePath);
|
||||
_diskProvider.DeleteFile(sourcePath);
|
||||
return TransferMode.Move;
|
||||
}
|
||||
}
|
||||
|
||||
if (isCifs && !isSameMount)
|
||||
{
|
||||
_logger.Trace("On cifs mount. Starting verified copy [{0}] to [{1}].", sourcePath, targetPath);
|
||||
TryCopyFileVerified(sourcePath, targetPath, originalSize);
|
||||
_logger.Trace("Copy successful, deleting source [{0}].", sourcePath);
|
||||
_diskProvider.DeleteFile(sourcePath);
|
||||
return TransferMode.Move;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user