Disabled verified file transfer on windows.

This commit is contained in:
Taloth Saldono 2015-06-05 22:51:16 +02:00
parent 5effca92b8
commit 546f4ab577
2 changed files with 42 additions and 1 deletions

View File

@ -47,10 +47,24 @@ namespace NzbDrone.Common.Test.DiskTests
Assert.Throws<IOException>(() => 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<IDiskProvider>()
.Verify(v => v.TryCreateHardLink(_sourcePath, _backupPath), Times.Never());
Mocker.GetMock<IDiskProvider>()
.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<IDiskProvider>()
@ -69,6 +83,8 @@ namespace NzbDrone.Common.Test.DiskTests
[Test]
public void should_retry_twice_if_partial_copy()
{
MonoOnly();
var retry = 0;
Mocker.GetMock<IDiskProvider>()
.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<IDiskProvider>()
@ -112,6 +132,8 @@ namespace NzbDrone.Common.Test.DiskTests
[Test]
public void should_remove_backup_if_move_throws()
{
MonoOnly();
WithSuccessfulHardlink(_sourcePath, _backupPath);
Mocker.GetMock<IDiskProvider>()
@ -126,6 +148,8 @@ namespace NzbDrone.Common.Test.DiskTests
[Test]
public void should_remove_partial_if_move_fails()
{
MonoOnly();
WithSuccessfulHardlink(_sourcePath, _backupPath);
Mocker.GetMock<IDiskProvider>()
@ -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);

View File

@ -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))