diff --git a/src/NzbDrone.Common.Test/DiskTests/DiskTransferServiceFixture.cs b/src/NzbDrone.Common.Test/DiskTests/DiskTransferServiceFixture.cs index 1f0bee20b..e8c942aa2 100644 --- a/src/NzbDrone.Common.Test/DiskTests/DiskTransferServiceFixture.cs +++ b/src/NzbDrone.Common.Test/DiskTests/DiskTransferServiceFixture.cs @@ -813,6 +813,24 @@ namespace NzbDrone.Common.Test.DiskTests .Verify(v => v.MoveFolder(src, dst), Times.Once()); } + [Test] + public void TransferFolder_should_not_use_movefolder_if_on_same_mount_but_target_already_exists() + { + WithEmulatedDiskProvider(); + + var src = @"C:\Base1\TestDir1".AsOsAgnostic(); + var dst = @"C:\Base1\TestDir2".AsOsAgnostic(); + + WithMockMount(@"C:\Base1".AsOsAgnostic()); + WithExistingFile(@"C:\Base1\TestDir1\test.file.txt".AsOsAgnostic()); + WithExistingFolder(dst); + + Subject.TransferFolder(src, dst, TransferMode.Move); + + Mocker.GetMock() + .Verify(v => v.MoveFolder(src, dst), Times.Never()); + } + [Test] public void TransferFolder_should_not_use_movefolder_if_on_same_mount_but_transactional() { diff --git a/src/NzbDrone.Common/Disk/DiskTransferService.cs b/src/NzbDrone.Common/Disk/DiskTransferService.cs index 79eacccd8..5a9ef8099 100644 --- a/src/NzbDrone.Common/Disk/DiskTransferService.cs +++ b/src/NzbDrone.Common/Disk/DiskTransferService.cs @@ -56,7 +56,7 @@ namespace NzbDrone.Common.Disk Ensure.That(sourcePath, () => sourcePath).IsValidPath(); Ensure.That(targetPath, () => targetPath).IsValidPath(); - if (mode == TransferMode.Move) + if (mode == TransferMode.Move && !_diskProvider.FolderExists(targetPath)) { if (verificationMode == DiskTransferVerificationMode.TryTransactional || verificationMode == DiskTransferVerificationMode.VerifyOnly) {