From 16ccff35bc3ec87365fd85f0bc063bacade4438a Mon Sep 17 00:00:00 2001 From: Michael Feinbier Date: Sun, 17 Sep 2023 10:43:05 +0200 Subject: [PATCH] Filter Items by ParentFolder --- .../PutioTests/PutioFixture.cs | 37 ++++++++++++++++--- .../Download/Clients/Putio/Putio.cs | 8 ++++ 2 files changed, 39 insertions(+), 6 deletions(-) diff --git a/src/NzbDrone.Core.Test/Download/DownloadClientTests/PutioTests/PutioFixture.cs b/src/NzbDrone.Core.Test/Download/DownloadClientTests/PutioTests/PutioFixture.cs index 41bcc9aef..54607677e 100644 --- a/src/NzbDrone.Core.Test/Download/DownloadClientTests/PutioTests/PutioFixture.cs +++ b/src/NzbDrone.Core.Test/Download/DownloadClientTests/PutioTests/PutioFixture.cs @@ -24,10 +24,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.PutioTests [SetUp] public void Setup() { - _settings = new PutioSettings - { - SaveParentId = "1", - }; + _settings = new PutioSettings(); Subject.Definition = new DownloadClientDefinition(); Subject.Definition.Settings = _settings; @@ -74,8 +71,16 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.PutioTests FileId = 1 }; - _completed_different_parent = _completed; - _completed_different_parent.SaveParentId = 2; + _completed_different_parent = new PutioTorrent + { + Hash = "HASH", + Status = PutioTorrentStatus.Completed, + Name = _title, + Size = 1000, + Downloaded = 1000, + SaveParentId = 2, + FileId = 1 + }; _seeding = new PutioTorrent { @@ -166,6 +171,26 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.PutioTests items.Should().HaveCount(6); } + [TestCase("1", 5)] + [TestCase("2", 1)] + [TestCase("3", 0)] + public void getItems_contains_only_items_with_matching_parent_id(string configuredParentId, int expectedCount) + { + GivenTorrents(new List + { + _queued, + _downloading, + _failed, + _completed, + _seeding, + _completed_different_parent + }); + + _settings.SaveParentId = configuredParentId; + + Subject.GetItems().Should().HaveCount(expectedCount); + } + [TestCase("WAITING", DownloadItemStatus.Queued)] [TestCase("PREPARING_DOWNLOAD", DownloadItemStatus.Queued)] [TestCase("COMPLETED", DownloadItemStatus.Completed)] diff --git a/src/NzbDrone.Core/Download/Clients/Putio/Putio.cs b/src/NzbDrone.Core/Download/Clients/Putio/Putio.cs index 81540c615..0f43f90d1 100644 --- a/src/NzbDrone.Core/Download/Clients/Putio/Putio.cs +++ b/src/NzbDrone.Core/Download/Clients/Putio/Putio.cs @@ -74,6 +74,12 @@ namespace NzbDrone.Core.Download.Clients.Putio continue; } + if (Settings.SaveParentId.IsNotNullOrWhiteSpace() && torrent.SaveParentId != long.Parse(Settings.SaveParentId)) + { + // torrent is not related to our parent folder + continue; + } + var item = new DownloadClientItem { DownloadId = torrent.Id.ToString(), @@ -88,6 +94,8 @@ namespace NzbDrone.Core.Download.Clients.Putio { if (torrent.FileId != 0) { + // How needs the output path need to look if we have remote files? + /* var file = _proxy.GetFile(torrent.FileId, Settings); var torrentPath = "/completed/" + file.Name;