diff --git a/src/NzbDrone.Common.Test/DiskTests/DiskTransferServiceFixture.cs b/src/NzbDrone.Common.Test/DiskTests/DiskTransferServiceFixture.cs index 000fb3577..8830ccea0 100644 --- a/src/NzbDrone.Common.Test/DiskTests/DiskTransferServiceFixture.cs +++ b/src/NzbDrone.Common.Test/DiskTests/DiskTransferServiceFixture.cs @@ -47,10 +47,24 @@ namespace NzbDrone.Common.Test.DiskTests Assert.Throws(() => Subject.TransferFile(_sourcePath, _targetPath, TransferMode.HardLink)); } + [Test] + public void should_not_use_verified_transfer_on_windows() + { + WindowsOnly(); + + var result = Subject.TransferFile(_sourcePath, _targetPath, TransferMode.Move); + + Mocker.GetMock() + .Verify(v => v.TryCreateHardLink(_sourcePath, _backupPath), Times.Never()); + + Mocker.GetMock() + .Verify(v => v.MoveFile(_sourcePath, _targetPath, false), Times.Once()); + } + [Test] public void should_retry_if_partial_copy() { - WithSuccessfulHardlink(_sourcePath, _backupPath); + MonoOnly(); var retry = 0; Mocker.GetMock() @@ -69,6 +83,8 @@ namespace NzbDrone.Common.Test.DiskTests [Test] public void should_retry_twice_if_partial_copy() { + MonoOnly(); + var retry = 0; Mocker.GetMock() .Setup(v => v.CopyFile(_sourcePath, _tempTargetPath, false)) @@ -87,6 +103,8 @@ namespace NzbDrone.Common.Test.DiskTests [Test] public void should_hardlink_before_move() { + MonoOnly(); + WithSuccessfulHardlink(_sourcePath, _backupPath); var result = Subject.TransferFile(_sourcePath, _targetPath, TransferMode.Move); @@ -98,6 +116,8 @@ namespace NzbDrone.Common.Test.DiskTests [Test] public void should_remove_source_after_move() { + MonoOnly(); + WithSuccessfulHardlink(_sourcePath, _backupPath); Mocker.GetMock() @@ -112,6 +132,8 @@ namespace NzbDrone.Common.Test.DiskTests [Test] public void should_remove_backup_if_move_throws() { + MonoOnly(); + WithSuccessfulHardlink(_sourcePath, _backupPath); Mocker.GetMock() @@ -126,6 +148,8 @@ namespace NzbDrone.Common.Test.DiskTests [Test] public void should_remove_partial_if_move_fails() { + MonoOnly(); + WithSuccessfulHardlink(_sourcePath, _backupPath); Mocker.GetMock() @@ -144,6 +168,8 @@ namespace NzbDrone.Common.Test.DiskTests [Test] public void should_fallback_to_copy_if_hardlink_failed() { + MonoOnly(); + WithFailedHardlink(); var result = Subject.TransferFile(_sourcePath, _targetPath, TransferMode.Move); diff --git a/src/NzbDrone.Common/Disk/DiskTransferService.cs b/src/NzbDrone.Common/Disk/DiskTransferService.cs index 52da91460..e8e671c78 100644 --- a/src/NzbDrone.Common/Disk/DiskTransferService.cs +++ b/src/NzbDrone.Common/Disk/DiskTransferService.cs @@ -6,6 +6,7 @@ using System.Text; using System.Threading; using NLog; using NzbDrone.Common.EnsureThat; +using NzbDrone.Common.EnvironmentInfo; using NzbDrone.Common.Extensions; namespace NzbDrone.Common.Disk @@ -34,6 +35,13 @@ namespace NzbDrone.Common.Disk Ensure.That(sourcePath, () => sourcePath).IsValidPath(); Ensure.That(targetPath, () => targetPath).IsValidPath(); + if (OsInfo.IsWindows) + { + // TODO: Atm we haven't seen partial transfers on windows so we disable verified transfer. + // (If enabled in the future, be sure to check specifically for ReFS, which doesn't support hardlinks.) + verified = false; + } + if (!_diskProvider.FolderExists(targetPath)) { _diskProvider.CreateFolder(targetPath); @@ -66,6 +74,13 @@ namespace NzbDrone.Common.Disk Ensure.That(sourcePath, () => sourcePath).IsValidPath(); Ensure.That(targetPath, () => targetPath).IsValidPath(); + if (OsInfo.IsWindows) + { + // TODO: Atm we haven't seen partial transfers on windows so we disable verified transfer. + // (If enabled in the future, be sure to check specifically for ReFS, which doesn't support hardlinks.) + verified = false; + } + _logger.Debug("{0} [{1}] > [{2}]", mode, sourcePath, targetPath); if (sourcePath.PathEquals(targetPath))