mirror of
https://github.com/Radarr/Radarr
synced 2024-12-25 09:21:57 +00:00
Fixed: Import single file torrents with a folder from QBittorrent
This commit is contained in:
parent
4c1de51b52
commit
4d43c3eb2b
2 changed files with 38 additions and 14 deletions
|
@ -311,6 +311,39 @@ public void single_file_torrent_outputpath_should_have_sanitised_name()
|
||||||
result.OutputPath.FullPath.Should().Be(Path.Combine(torrent.SavePath, file.Name));
|
result.OutputPath.FullPath.Should().Be(Path.Combine(torrent.SavePath, file.Name));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void single_file_torrent_with_folder_should_only_have_first_subfolder()
|
||||||
|
{
|
||||||
|
var torrent = new QBittorrentTorrent
|
||||||
|
{
|
||||||
|
Hash = "HASH",
|
||||||
|
Name = @"Droned.S01E01.Test\'s.1080p.WEB-DL-DRONE",
|
||||||
|
Size = 1000,
|
||||||
|
Progress = 0.7,
|
||||||
|
Eta = 8640000,
|
||||||
|
State = "stalledDL",
|
||||||
|
Label = "",
|
||||||
|
SavePath = @"C:\Torrents".AsOsAgnostic()
|
||||||
|
};
|
||||||
|
|
||||||
|
var file = new QBittorrentTorrentFile
|
||||||
|
{
|
||||||
|
Name = "Folder/Droned.S01E01.Tests.1080p.WEB-DL-DRONE.mkv"
|
||||||
|
};
|
||||||
|
|
||||||
|
GivenTorrents(new List<QBittorrentTorrent> { torrent });
|
||||||
|
GivenTorrentFiles(torrent.Hash, new List<QBittorrentTorrentFile> { file });
|
||||||
|
|
||||||
|
var item = new DownloadClientItem
|
||||||
|
{
|
||||||
|
DownloadId = torrent.Hash
|
||||||
|
};
|
||||||
|
|
||||||
|
var result = Subject.GetImportItem(item, null);
|
||||||
|
|
||||||
|
result.OutputPath.FullPath.Should().Be(Path.Combine(torrent.SavePath, "Folder"));
|
||||||
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void multi_file_torrent_outputpath_should_have_sanitised_name()
|
public void multi_file_torrent_outputpath_should_have_sanitised_name()
|
||||||
{
|
{
|
||||||
|
|
|
@ -253,23 +253,14 @@ public override DownloadClientItem GetImportItem(DownloadClientItem item, Downlo
|
||||||
|
|
||||||
var result = item.Clone();
|
var result = item.Clone();
|
||||||
|
|
||||||
OsPath outputPath;
|
// get the first subdirectory - QBittorrent returns `/` path separators even on windows...
|
||||||
if (files.Count == 1)
|
var relativePath = new OsPath(files[0].Name);
|
||||||
|
while (!relativePath.Directory.IsEmpty)
|
||||||
{
|
{
|
||||||
outputPath = savePath + files[0].Name;
|
relativePath = relativePath.Directory;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
// we have multiple files in the torrent so just get
|
|
||||||
// the first subdirectory
|
|
||||||
var relativePath = new OsPath(files[0].Name);
|
|
||||||
while (!relativePath.Directory.IsEmpty)
|
|
||||||
{
|
|
||||||
relativePath = relativePath.Directory;
|
|
||||||
}
|
|
||||||
|
|
||||||
outputPath = savePath + relativePath.FileName;
|
var outputPath = savePath + relativePath.FileName;
|
||||||
}
|
|
||||||
|
|
||||||
result.OutputPath = _remotePathMappingService.RemapRemoteToLocal(Settings.Host, outputPath);
|
result.OutputPath = _remotePathMappingService.RemapRemoteToLocal(Settings.Host, outputPath);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue