mirror of
https://github.com/Radarr/Radarr
synced 2024-12-21 23:42:23 +00:00
Fixed: Moving files for torrents when Remove Completed is disabled
(cherry picked from commit 78a0def46a4c8628d9bcf6af2701aa35b3f959b9)
This commit is contained in:
parent
74246df881
commit
12ca04b298
3 changed files with 49 additions and 3 deletions
|
@ -67,8 +67,9 @@ public void Setup()
|
|||
.Returns(new List<MovieHistory>());
|
||||
|
||||
_downloadClientItem = Builder<DownloadClientItem>.CreateNew()
|
||||
.With(d => d.OutputPath = new OsPath(outputPath))
|
||||
.Build();
|
||||
.With(d => d.OutputPath = new OsPath(outputPath))
|
||||
.With(d => d.DownloadClientInfo = new DownloadClientItemClientInfo())
|
||||
.Build();
|
||||
}
|
||||
|
||||
private void GivenNewDownload()
|
||||
|
@ -193,6 +194,7 @@ public void should_copy_when_cannot_move_files_downloads()
|
|||
GivenNewDownload();
|
||||
_downloadClientItem.Title = "30.Rock.S01E01";
|
||||
_downloadClientItem.CanMoveFiles = false;
|
||||
_downloadClientItem.DownloadClientInfo = null;
|
||||
|
||||
Subject.Import(new List<ImportDecision> { _approvedDecisions.First() }, true, _downloadClientItem);
|
||||
|
||||
|
@ -200,6 +202,48 @@ public void should_copy_when_cannot_move_files_downloads()
|
|||
.Verify(v => v.UpgradeMovieFile(It.IsAny<MovieFile>(), _approvedDecisions.First().LocalMovie, true), Times.Once());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_copy_when_remove_completed_downloads_is_disabled_and_can_move_files()
|
||||
{
|
||||
GivenNewDownload();
|
||||
_downloadClientItem.Title = "30.Rock.S01E01";
|
||||
_downloadClientItem.CanMoveFiles = true;
|
||||
_downloadClientItem.DownloadClientInfo.RemoveCompletedDownloads = false;
|
||||
|
||||
Subject.Import(new List<ImportDecision> { _approvedDecisions.First() }, true, _downloadClientItem);
|
||||
|
||||
Mocker.GetMock<IUpgradeMediaFiles>()
|
||||
.Verify(v => v.UpgradeEpisodeFile(It.IsAny<EpisodeFile>(), _approvedDecisions.First().LocalEpisode, true), Times.Once());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_copy_when_remove_completed_downloads_is_enabled_and_cannot_move_files()
|
||||
{
|
||||
GivenNewDownload();
|
||||
_downloadClientItem.Title = "30.Rock.S01E01";
|
||||
_downloadClientItem.CanMoveFiles = false;
|
||||
_downloadClientItem.DownloadClientInfo.RemoveCompletedDownloads = true;
|
||||
|
||||
Subject.Import(new List<ImportDecision> { _approvedDecisions.First() }, true, _downloadClientItem);
|
||||
|
||||
Mocker.GetMock<IUpgradeMediaFiles>()
|
||||
.Verify(v => v.UpgradeEpisodeFile(It.IsAny<EpisodeFile>(), _approvedDecisions.First().LocalEpisode, true), Times.Once());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_move_when_remove_completed_downloads_is_enabled_and_can_move_files()
|
||||
{
|
||||
GivenNewDownload();
|
||||
_downloadClientItem.Title = "30.Rock.S01E01";
|
||||
_downloadClientItem.CanMoveFiles = true;
|
||||
_downloadClientItem.DownloadClientInfo.RemoveCompletedDownloads = true;
|
||||
|
||||
Subject.Import(new List<ImportDecision> { _approvedDecisions.First() }, true, _downloadClientItem);
|
||||
|
||||
Mocker.GetMock<IUpgradeMediaFiles>()
|
||||
.Verify(v => v.UpgradeEpisodeFile(It.IsAny<EpisodeFile>(), _approvedDecisions.First().LocalEpisode, false), Times.Once());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_use_override_importmode()
|
||||
{
|
||||
|
|
|
@ -38,6 +38,7 @@ public class DownloadClientItemClientInfo
|
|||
public string Type { get; set; }
|
||||
public int Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public bool RemoveCompletedDownloads { get; set; }
|
||||
public bool HasPostImportCategory { get; set; }
|
||||
|
||||
public static DownloadClientItemClientInfo FromDownloadClient<TSettings>(
|
||||
|
@ -50,6 +51,7 @@ public static DownloadClientItemClientInfo FromDownloadClient<TSettings>(
|
|||
Type = downloadClient.Name,
|
||||
Id = downloadClient.Definition.Id,
|
||||
Name = downloadClient.Definition.Name,
|
||||
RemoveCompletedDownloads = downloadClient.Definition is DownloadClientDefinition { RemoveCompletedDownloads: true },
|
||||
HasPostImportCategory = hasPostImportCategory
|
||||
};
|
||||
}
|
||||
|
|
|
@ -118,7 +118,7 @@ public List<ImportResult> Import(List<ImportDecision> decisions, bool newDownloa
|
|||
{
|
||||
default:
|
||||
case ImportMode.Auto:
|
||||
copyOnly = downloadClientItem != null && !downloadClientItem.CanMoveFiles;
|
||||
copyOnly = downloadClientItem is { CanMoveFiles: false } or { DownloadClientInfo.RemoveCompletedDownloads: false };
|
||||
break;
|
||||
case ImportMode.Move:
|
||||
copyOnly = false;
|
||||
|
|
Loading…
Reference in a new issue