mirror of
https://github.com/Sonarr/Sonarr
synced 2025-12-06 08:28:37 +01:00
Merge 1fc11e2d2a into 1178c98341
This commit is contained in:
commit
b3a0c4c7f3
4 changed files with 34 additions and 4 deletions
|
|
@ -579,6 +579,27 @@ public void MoveFolder_should_rename_casesensitive_folder()
|
|||
Directory.Exists(destination.FullName).Should().Be(true);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TransferFile_should_find_files_with_multiple_slashes_within_their_path()
|
||||
{
|
||||
WithRealDiskProvider();
|
||||
|
||||
var root = GetFilledTempFolder();
|
||||
var rootDir = root.FullName;
|
||||
var fromFileName = "source-file";
|
||||
var from = Path.Combine(rootDir, fromFileName);
|
||||
var to = Path.Combine(rootDir, "destination-file");
|
||||
|
||||
var oneSlash = new string(Path.DirectorySeparatorChar, 1);
|
||||
var threeSlashes = new string(Path.DirectorySeparatorChar, 3);
|
||||
var overSlashed = Path.Combine(rootDir.Replace(oneSlash, threeSlashes), fromFileName);
|
||||
|
||||
File.WriteAllText(from, "Source file");
|
||||
|
||||
var mode = Subject.TransferFile(overSlashed, to, TransferMode.Copy);
|
||||
mode.Should().Be(TransferMode.Copy);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_throw_if_destination_is_readonly()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -28,15 +28,15 @@ public DiskTransferService(IDiskProvider diskProvider, Logger logger)
|
|||
|
||||
private string ResolveRealParentPath(string path)
|
||||
{
|
||||
var parentPath = path.GetParentPath();
|
||||
if (!_diskProvider.FolderExists(parentPath))
|
||||
if (!_diskProvider.FolderExists(path.GetParentPath()))
|
||||
{
|
||||
return path;
|
||||
}
|
||||
|
||||
var cleanPath = path.GetCleanPath();
|
||||
var parentPath = cleanPath.GetParentPath();
|
||||
var realParentPath = parentPath.GetActualCasing();
|
||||
|
||||
var partialChildPath = path.Substring(parentPath.Length);
|
||||
var partialChildPath = cleanPath.Substring(parentPath.Length);
|
||||
|
||||
return realParentPath + partialChildPath;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
using NzbDrone.Core.Download;
|
||||
using NzbDrone.Core.Download.Clients.RQBit;
|
||||
using NzbDrone.Core.MediaFiles.TorrentInfo;
|
||||
using NzbDrone.Test.Common;
|
||||
|
||||
namespace NzbDrone.Core.Test.Download.DownloadClientTests.RQBitTests
|
||||
{
|
||||
|
|
@ -212,6 +213,8 @@ public void GetItems_should_ignore_torrents_with_empty_path()
|
|||
|
||||
items.Should().HaveCount(1);
|
||||
items.First().Title.Should().Be("Test2");
|
||||
|
||||
ExceptionVerification.ExpectedWarns(1);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
|
@ -229,6 +232,8 @@ public void GetItems_should_ignore_torrents_with_relative_path()
|
|||
|
||||
items.Should().HaveCount(1);
|
||||
items.First().Title.Should().Be("Test2");
|
||||
|
||||
ExceptionVerification.ExpectedWarns(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -145,6 +145,8 @@ public void should_delete_existing_file_fromdb_if_file_doesnt_exist()
|
|||
Subject.UpgradeEpisodeFile(_episodeFile, _localEpisode);
|
||||
|
||||
Mocker.GetMock<IMediaFileService>().Verify(v => v.Delete(_localEpisode.Episodes.Single().EpisodeFile, DeleteMediaFileReason.Upgrade), Times.Once());
|
||||
|
||||
ExceptionVerification.ExpectedWarns(1);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
|
@ -159,6 +161,8 @@ public void should_not_try_to_recyclebin_existing_file_if_file_doesnt_exist()
|
|||
Subject.UpgradeEpisodeFile(_episodeFile, _localEpisode);
|
||||
|
||||
Mocker.GetMock<IRecycleBinProvider>().Verify(v => v.DeleteFile(It.IsAny<string>(), It.IsAny<string>()), Times.Never());
|
||||
|
||||
ExceptionVerification.ExpectedWarns(1);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
|
|
|||
Loading…
Reference in a new issue