1
0
Fork 0
mirror of https://github.com/Sonarr/Sonarr synced 2024-12-22 07:43:01 +00:00

Fixed: Moving files for torrents when Remove Completed is disabled

This commit is contained in:
Bogdan 2024-07-31 07:27:19 +03:00 committed by GitHub
parent 11a9dcb389
commit 78a0def46a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 49 additions and 3 deletions

View file

@ -74,8 +74,9 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport
.Returns(new List<EpisodeHistory>());
_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()
@ -201,6 +202,7 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport
GivenNewDownload();
_downloadClientItem.Title = "30.Rock.S01E01";
_downloadClientItem.CanMoveFiles = false;
_downloadClientItem.DownloadClientInfo = null;
Subject.Import(new List<ImportDecision> { _approvedDecisions.First() }, true, _downloadClientItem);
@ -208,6 +210,48 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport
.Verify(v => v.UpgradeEpisodeFile(It.IsAny<EpisodeFile>(), _approvedDecisions.First().LocalEpisode, 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()
{

View file

@ -37,6 +37,7 @@ namespace NzbDrone.Core.Download
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>(
@ -49,6 +50,7 @@ namespace NzbDrone.Core.Download
Type = downloadClient.Name,
Id = downloadClient.Definition.Id,
Name = downloadClient.Definition.Name,
RemoveCompletedDownloads = downloadClient.Definition is DownloadClientDefinition { RemoveCompletedDownloads: true },
HasPostImportCategory = hasPostImportCategory
};
}

View file

@ -140,7 +140,7 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport
{
default:
case ImportMode.Auto:
copyOnly = downloadClientItem != null && !downloadClientItem.CanMoveFiles;
copyOnly = downloadClientItem is { CanMoveFiles: false } or { DownloadClientInfo.RemoveCompletedDownloads: false };
break;
case ImportMode.Move:
copyOnly = false;