From 3e4ebe8aca89b3d4bab00fe1ce1f9b2e05af08b1 Mon Sep 17 00:00:00 2001 From: ta264 Date: Mon, 16 Nov 2020 21:34:49 +0000 Subject: [PATCH] Pull DownloadClientItemClientInfo part of 824d315a --- .../DownloadClientFixtureBase.cs | 4 +++- .../TrackedDownloadServiceFixture.cs | 12 +++++++++++ .../Checks/RemotePathMappingCheckFixture.cs | 12 ++++++++--- .../HistoryTests/HistoryServiceFixture.cs | 8 +++++++- .../MediaFiles/ImportApprovedTracksFixture.cs | 8 +++++--- .../QueueTests/QueueServiceFixture.cs | 4 ++++ .../Clients/Blackhole/TorrentBlackhole.cs | 2 +- .../Clients/Blackhole/UsenetBlackhole.cs | 2 +- .../Download/Clients/Deluge/Deluge.cs | 2 +- .../DownloadStation/TorrentDownloadStation.cs | 2 +- .../DownloadStation/UsenetDownloadStation.cs | 2 +- .../Download/Clients/Hadouken/Hadouken.cs | 2 +- .../Download/Clients/NzbVortex/NzbVortex.cs | 2 +- .../Download/Clients/Nzbget/Nzbget.cs | 4 ++-- .../Download/Clients/Pneumatic/Pneumatic.cs | 2 +- .../Clients/QBittorrent/QBittorrent.cs | 2 +- .../Download/Clients/Sabnzbd/Sabnzbd.cs | 4 ++-- .../Clients/Transmission/TransmissionBase.cs | 2 +- .../Download/Clients/rTorrent/RTorrent.cs | 2 +- .../Download/Clients/uTorrent/UTorrent.cs | 2 +- .../Download/DownloadClientItem.cs | 20 +++++++++++++------ .../Download/DownloadEventHub.cs | 4 ++-- .../Download/DownloadIgnoredEvent.cs | 2 +- .../Download/IgnoredDownloadService.cs | 18 ++++++++--------- .../TrackedDownloadService.cs | 2 +- src/NzbDrone.Core/History/HistoryService.cs | 2 +- .../MediaFiles/Events/BookImportedEvent.cs | 2 +- .../Events/TrackImportFailedEvent.cs | 2 +- .../MediaFiles/Events/TrackImportedEvent.cs | 2 +- src/NzbDrone.Core/Queue/QueueService.cs | 2 +- 30 files changed, 88 insertions(+), 48 deletions(-) diff --git a/src/NzbDrone.Core.Test/Download/DownloadClientTests/DownloadClientFixtureBase.cs b/src/NzbDrone.Core.Test/Download/DownloadClientTests/DownloadClientFixtureBase.cs index fd2ff3e67..38534971f 100644 --- a/src/NzbDrone.Core.Test/Download/DownloadClientTests/DownloadClientFixtureBase.cs +++ b/src/NzbDrone.Core.Test/Download/DownloadClientTests/DownloadClientFixtureBase.cs @@ -61,7 +61,9 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests protected void VerifyIdentifiable(DownloadClientItem downloadClientItem) { - downloadClientItem.DownloadClient.Should().Be(Subject.Definition.Name); + downloadClientItem.DownloadClientInfo.Protocol.Should().Be(Subject.Protocol); + downloadClientItem.DownloadClientInfo.Id.Should().Be(Subject.Definition.Id); + downloadClientItem.DownloadClientInfo.Name.Should().Be(Subject.Definition.Name); downloadClientItem.DownloadId.Should().NotBeNullOrEmpty(); downloadClientItem.Title.Should().NotBeNullOrEmpty(); } diff --git a/src/NzbDrone.Core.Test/Download/TrackedDownloads/TrackedDownloadServiceFixture.cs b/src/NzbDrone.Core.Test/Download/TrackedDownloads/TrackedDownloadServiceFixture.cs index 1b3572b2c..f5f00c6de 100644 --- a/src/NzbDrone.Core.Test/Download/TrackedDownloads/TrackedDownloadServiceFixture.cs +++ b/src/NzbDrone.Core.Test/Download/TrackedDownloads/TrackedDownloadServiceFixture.cs @@ -64,6 +64,12 @@ namespace NzbDrone.Core.Test.Download.TrackedDownloads { Title = "The torrent release folder", DownloadId = "35238", + DownloadClientInfo = new DownloadClientItemClientInfo + { + Protocol = client.Protocol, + Id = client.Id, + Name = client.Name + } }; var trackedDownload = Subject.TrackDownload(client, item); @@ -105,6 +111,12 @@ namespace NzbDrone.Core.Test.Download.TrackedDownloads { Title = "Audio Artist - Audio Album [2018 - FLAC]", DownloadId = "35238", + DownloadClientInfo = new DownloadClientItemClientInfo + { + Protocol = client.Protocol, + Id = client.Id, + Name = client.Name + } }; // get a tracked download in place diff --git a/src/NzbDrone.Core.Test/HealthCheck/Checks/RemotePathMappingCheckFixture.cs b/src/NzbDrone.Core.Test/HealthCheck/Checks/RemotePathMappingCheckFixture.cs index e28dce7c2..1a38e7388 100644 --- a/src/NzbDrone.Core.Test/HealthCheck/Checks/RemotePathMappingCheckFixture.cs +++ b/src/NzbDrone.Core.Test/HealthCheck/Checks/RemotePathMappingCheckFixture.cs @@ -9,6 +9,7 @@ using NzbDrone.Common.EnvironmentInfo; using NzbDrone.Core.Download; using NzbDrone.Core.Download.Clients; using NzbDrone.Core.HealthCheck.Checks; +using NzbDrone.Core.Indexers; using NzbDrone.Core.MediaFiles; using NzbDrone.Core.MediaFiles.Events; using NzbDrone.Core.Parser.Model; @@ -39,7 +40,12 @@ namespace NzbDrone.Core.Test.HealthCheck.Checks { _downloadItem = new DownloadClientItem { - DownloadClient = "Test", + DownloadClientInfo = new DownloadClientItemClientInfo + { + Protocol = DownloadProtocol.Usenet, + Id = 1, + Name = "Test" + }, DownloadId = "TestId", OutputPath = new OsPath(_downloadItemPath) }; @@ -166,7 +172,7 @@ namespace NzbDrone.Core.Test.HealthCheck.Checks public void should_return_ok_on_track_imported_event() { GivenFolderExists(_downloadRootPath); - var importEvent = new TrackImportedEvent(new LocalBook(), new BookFile(), new List(), true, new DownloadClientItem()); + var importEvent = new TrackImportedEvent(new LocalBook(), new BookFile(), new List(), true, new DownloadClientItem { DownloadClientInfo = new DownloadClientItemClientInfo() }); Subject.Check(importEvent).ShouldBeOk(); } @@ -180,7 +186,7 @@ namespace NzbDrone.Core.Test.HealthCheck.Checks }; GivenFileExists(localTrack.Path); - var importEvent = new TrackImportFailedEvent(new Exception(), localTrack, true, new DownloadClientItem()); + var importEvent = new TrackImportFailedEvent(new Exception(), localTrack, true, new DownloadClientItem { DownloadClientInfo = new DownloadClientItemClientInfo() }); Subject.Check(importEvent).ShouldBeError(wikiFragment: "permissions-error"); } diff --git a/src/NzbDrone.Core.Test/HistoryTests/HistoryServiceFixture.cs b/src/NzbDrone.Core.Test/HistoryTests/HistoryServiceFixture.cs index a2c7708f0..156ecca90 100644 --- a/src/NzbDrone.Core.Test/HistoryTests/HistoryServiceFixture.cs +++ b/src/NzbDrone.Core.Test/HistoryTests/HistoryServiceFixture.cs @@ -7,6 +7,7 @@ using NUnit.Framework; using NzbDrone.Core.Books; using NzbDrone.Core.Download; using NzbDrone.Core.History; +using NzbDrone.Core.Indexers; using NzbDrone.Core.MediaFiles; using NzbDrone.Core.MediaFiles.Events; using NzbDrone.Core.Parser.Model; @@ -56,7 +57,12 @@ namespace NzbDrone.Core.Test.HistoryTests var downloadClientItem = new DownloadClientItem { - DownloadClient = "sab", + DownloadClientInfo = new DownloadClientItemClientInfo + { + Protocol = DownloadProtocol.Usenet, + Id = 1, + Name = "sab" + }, DownloadId = "abcd" }; diff --git a/src/NzbDrone.Core.Test/MediaFiles/ImportApprovedTracksFixture.cs b/src/NzbDrone.Core.Test/MediaFiles/ImportApprovedTracksFixture.cs index 2b944b28e..9f0653a11 100644 --- a/src/NzbDrone.Core.Test/MediaFiles/ImportApprovedTracksFixture.cs +++ b/src/NzbDrone.Core.Test/MediaFiles/ImportApprovedTracksFixture.cs @@ -28,6 +28,7 @@ namespace NzbDrone.Core.Test.MediaFiles private List> _approvedDecisions; private DownloadClientItem _downloadClientItem; + private DownloadClientItemClientInfo _clientInfo; [SetUp] public void Setup() @@ -74,7 +75,8 @@ namespace NzbDrone.Core.Test.MediaFiles .Setup(s => s.UpgradeBookFile(It.IsAny(), It.IsAny(), It.IsAny())) .Returns(new BookFileMoveResult()); - _downloadClientItem = Builder.CreateNew().Build(); + _clientInfo = Builder.CreateNew().Build(); + _downloadClientItem = Builder.CreateNew().With(x => x.DownloadClientInfo = _clientInfo).Build(); Mocker.GetMock() .Setup(s => s.GetFilesByBook(It.IsAny())) @@ -186,7 +188,7 @@ namespace NzbDrone.Core.Test.MediaFiles [Test] public void should_copy_when_cannot_move_files_downloads() { - Subject.Import(new List> { _approvedDecisions.First() }, true, new DownloadClientItem { Title = "Alien.Ant.Farm-Truant", CanMoveFiles = false }); + Subject.Import(new List> { _approvedDecisions.First() }, true, new DownloadClientItem { Title = "Alien.Ant.Farm-Truant", CanMoveFiles = false, DownloadClientInfo = _clientInfo }); Mocker.GetMock() .Verify(v => v.UpgradeBookFile(It.IsAny(), _approvedDecisions.First().Item, true), Times.Once()); @@ -195,7 +197,7 @@ namespace NzbDrone.Core.Test.MediaFiles [Test] public void should_use_override_importmode() { - Subject.Import(new List> { _approvedDecisions.First() }, true, new DownloadClientItem { Title = "Alien.Ant.Farm-Truant", CanMoveFiles = false }, ImportMode.Move); + Subject.Import(new List> { _approvedDecisions.First() }, true, new DownloadClientItem { Title = "Alien.Ant.Farm-Truant", CanMoveFiles = false, DownloadClientInfo = _clientInfo }, ImportMode.Move); Mocker.GetMock() .Verify(v => v.UpgradeBookFile(It.IsAny(), _approvedDecisions.First().Item, false), Times.Once()); diff --git a/src/NzbDrone.Core.Test/QueueTests/QueueServiceFixture.cs b/src/NzbDrone.Core.Test/QueueTests/QueueServiceFixture.cs index af1d0d386..1e155bc39 100644 --- a/src/NzbDrone.Core.Test/QueueTests/QueueServiceFixture.cs +++ b/src/NzbDrone.Core.Test/QueueTests/QueueServiceFixture.cs @@ -6,6 +6,7 @@ using FluentAssertions; using Moq; using NUnit.Framework; using NzbDrone.Core.Books; +using NzbDrone.Core.Download; using NzbDrone.Core.Download.TrackedDownloads; using NzbDrone.Core.History; using NzbDrone.Core.Parser.Model; @@ -22,8 +23,11 @@ namespace NzbDrone.Core.Test.QueueTests [SetUp] public void SetUp() { + var downloadClientInfo = Builder.CreateNew().Build(); + var downloadItem = Builder.CreateNew() .With(v => v.RemainingTime = TimeSpan.FromSeconds(10)) + .With(v => v.DownloadClientInfo = downloadClientInfo) .Build(); var artist = Builder.CreateNew() diff --git a/src/NzbDrone.Core/Download/Clients/Blackhole/TorrentBlackhole.cs b/src/NzbDrone.Core/Download/Clients/Blackhole/TorrentBlackhole.cs index 18e06eaf7..58980cc46 100644 --- a/src/NzbDrone.Core/Download/Clients/Blackhole/TorrentBlackhole.cs +++ b/src/NzbDrone.Core/Download/Clients/Blackhole/TorrentBlackhole.cs @@ -87,7 +87,7 @@ namespace NzbDrone.Core.Download.Clients.Blackhole { yield return new DownloadClientItem { - DownloadClient = Definition.Name, + DownloadClientInfo = DownloadClientItemClientInfo.FromDownloadClient(this), DownloadId = Definition.Name + "_" + item.DownloadId, Category = "Readarr", Title = item.Title, diff --git a/src/NzbDrone.Core/Download/Clients/Blackhole/UsenetBlackhole.cs b/src/NzbDrone.Core/Download/Clients/Blackhole/UsenetBlackhole.cs index 7e5ab3715..4c37b4182 100644 --- a/src/NzbDrone.Core/Download/Clients/Blackhole/UsenetBlackhole.cs +++ b/src/NzbDrone.Core/Download/Clients/Blackhole/UsenetBlackhole.cs @@ -59,7 +59,7 @@ namespace NzbDrone.Core.Download.Clients.Blackhole { yield return new DownloadClientItem { - DownloadClient = Definition.Name, + DownloadClientInfo = DownloadClientItemClientInfo.FromDownloadClient(this), DownloadId = Definition.Name + "_" + item.DownloadId, Category = "Readarr", Title = item.Title, diff --git a/src/NzbDrone.Core/Download/Clients/Deluge/Deluge.cs b/src/NzbDrone.Core/Download/Clients/Deluge/Deluge.cs index ec4d93f6e..568f69eca 100644 --- a/src/NzbDrone.Core/Download/Clients/Deluge/Deluge.cs +++ b/src/NzbDrone.Core/Download/Clients/Deluge/Deluge.cs @@ -133,7 +133,7 @@ namespace NzbDrone.Core.Download.Clients.Deluge item.Title = torrent.Name; item.Category = Settings.MusicCategory; - item.DownloadClient = Definition.Name; + item.DownloadClientInfo = DownloadClientItemClientInfo.FromDownloadClient(this); var outputPath = _remotePathMappingService.RemapRemoteToLocal(Settings.Host, new OsPath(torrent.DownloadPath)); item.OutputPath = outputPath + torrent.Name; diff --git a/src/NzbDrone.Core/Download/Clients/DownloadStation/TorrentDownloadStation.cs b/src/NzbDrone.Core/Download/Clients/DownloadStation/TorrentDownloadStation.cs index ade7b0257..887474c9b 100644 --- a/src/NzbDrone.Core/Download/Clients/DownloadStation/TorrentDownloadStation.cs +++ b/src/NzbDrone.Core/Download/Clients/DownloadStation/TorrentDownloadStation.cs @@ -85,7 +85,7 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation var item = new DownloadClientItem() { Category = Settings.MusicCategory, - DownloadClient = Definition.Name, + DownloadClientInfo = DownloadClientItemClientInfo.FromDownloadClient(this), DownloadId = CreateDownloadId(torrent.Id, serialNumber), Title = torrent.Title, TotalSize = torrent.Size, diff --git a/src/NzbDrone.Core/Download/Clients/DownloadStation/UsenetDownloadStation.cs b/src/NzbDrone.Core/Download/Clients/DownloadStation/UsenetDownloadStation.cs index be853f6d9..62947b675 100644 --- a/src/NzbDrone.Core/Download/Clients/DownloadStation/UsenetDownloadStation.cs +++ b/src/NzbDrone.Core/Download/Clients/DownloadStation/UsenetDownloadStation.cs @@ -95,7 +95,7 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation var item = new DownloadClientItem() { Category = Settings.MusicCategory, - DownloadClient = Definition.Name, + DownloadClientInfo = DownloadClientItemClientInfo.FromDownloadClient(this), DownloadId = CreateDownloadId(nzb.Id, serialNumber), Title = nzb.Title, TotalSize = nzb.Size, diff --git a/src/NzbDrone.Core/Download/Clients/Hadouken/Hadouken.cs b/src/NzbDrone.Core/Download/Clients/Hadouken/Hadouken.cs index 912a4d451..e46252bcb 100644 --- a/src/NzbDrone.Core/Download/Clients/Hadouken/Hadouken.cs +++ b/src/NzbDrone.Core/Download/Clients/Hadouken/Hadouken.cs @@ -55,7 +55,7 @@ namespace NzbDrone.Core.Download.Clients.Hadouken var item = new DownloadClientItem { - DownloadClient = Definition.Name, + DownloadClientInfo = DownloadClientItemClientInfo.FromDownloadClient(this), DownloadId = torrent.InfoHash.ToUpper(), OutputPath = outputPath + torrent.Name, RemainingSize = torrent.TotalSize - torrent.DownloadedBytes, diff --git a/src/NzbDrone.Core/Download/Clients/NzbVortex/NzbVortex.cs b/src/NzbDrone.Core/Download/Clients/NzbVortex/NzbVortex.cs index 7b7c31c85..9aec8af7f 100644 --- a/src/NzbDrone.Core/Download/Clients/NzbVortex/NzbVortex.cs +++ b/src/NzbDrone.Core/Download/Clients/NzbVortex/NzbVortex.cs @@ -56,7 +56,7 @@ namespace NzbDrone.Core.Download.Clients.NzbVortex { var queueItem = new DownloadClientItem(); - queueItem.DownloadClient = Definition.Name; + queueItem.DownloadClientInfo = DownloadClientItemClientInfo.FromDownloadClient(this); queueItem.DownloadId = vortexQueueItem.AddUUID ?? vortexQueueItem.Id.ToString(); queueItem.Category = vortexQueueItem.GroupName; queueItem.Title = vortexQueueItem.UiTitle; diff --git a/src/NzbDrone.Core/Download/Clients/Nzbget/Nzbget.cs b/src/NzbDrone.Core/Download/Clients/Nzbget/Nzbget.cs index d2dc680c3..db95dd9d7 100644 --- a/src/NzbDrone.Core/Download/Clients/Nzbget/Nzbget.cs +++ b/src/NzbDrone.Core/Download/Clients/Nzbget/Nzbget.cs @@ -72,7 +72,7 @@ namespace NzbDrone.Core.Download.Clients.Nzbget queueItem.Title = item.NzbName; queueItem.TotalSize = totalSize; queueItem.Category = item.Category; - queueItem.DownloadClient = Definition.Name; + queueItem.DownloadClientInfo = DownloadClientItemClientInfo.FromDownloadClient(this); queueItem.CanMoveFiles = true; queueItem.CanBeRemoved = true; @@ -119,7 +119,7 @@ namespace NzbDrone.Core.Download.Clients.Nzbget var historyItem = new DownloadClientItem(); var itemDir = item.FinalDir.IsNullOrWhiteSpace() ? item.DestDir : item.FinalDir; - historyItem.DownloadClient = Definition.Name; + historyItem.DownloadClientInfo = DownloadClientItemClientInfo.FromDownloadClient(this); historyItem.DownloadId = droneParameter == null ? item.Id.ToString() : droneParameter.Value.ToString(); historyItem.Title = item.Name; historyItem.TotalSize = MakeInt64(item.FileSizeHi, item.FileSizeLo); diff --git a/src/NzbDrone.Core/Download/Clients/Pneumatic/Pneumatic.cs b/src/NzbDrone.Core/Download/Clients/Pneumatic/Pneumatic.cs index e9d9a9030..6b3c3ace5 100644 --- a/src/NzbDrone.Core/Download/Clients/Pneumatic/Pneumatic.cs +++ b/src/NzbDrone.Core/Download/Clients/Pneumatic/Pneumatic.cs @@ -72,7 +72,7 @@ namespace NzbDrone.Core.Download.Clients.Pneumatic var historyItem = new DownloadClientItem { - DownloadClient = Definition.Name, + DownloadClientInfo = DownloadClientItemClientInfo.FromDownloadClient(this), DownloadId = GetDownloadClientId(file), Title = title, diff --git a/src/NzbDrone.Core/Download/Clients/QBittorrent/QBittorrent.cs b/src/NzbDrone.Core/Download/Clients/QBittorrent/QBittorrent.cs index 486fe54f9..cb8a57c0d 100644 --- a/src/NzbDrone.Core/Download/Clients/QBittorrent/QBittorrent.cs +++ b/src/NzbDrone.Core/Download/Clients/QBittorrent/QBittorrent.cs @@ -137,7 +137,7 @@ namespace NzbDrone.Core.Download.Clients.QBittorrent Category = torrent.Category.IsNotNullOrWhiteSpace() ? torrent.Category : torrent.Label, Title = torrent.Name, TotalSize = torrent.Size, - DownloadClient = Definition.Name, + DownloadClientInfo = DownloadClientItemClientInfo.FromDownloadClient(this), RemainingSize = (long)(torrent.Size * (1.0 - torrent.Progress)), RemainingTime = GetRemainingTime(torrent), SeedRatio = torrent.Ratio diff --git a/src/NzbDrone.Core/Download/Clients/Sabnzbd/Sabnzbd.cs b/src/NzbDrone.Core/Download/Clients/Sabnzbd/Sabnzbd.cs index 56cffd61e..839c4274a 100644 --- a/src/NzbDrone.Core/Download/Clients/Sabnzbd/Sabnzbd.cs +++ b/src/NzbDrone.Core/Download/Clients/Sabnzbd/Sabnzbd.cs @@ -62,7 +62,7 @@ namespace NzbDrone.Core.Download.Clients.Sabnzbd } var queueItem = new DownloadClientItem(); - queueItem.DownloadClient = Definition.Name; + queueItem.DownloadClientInfo = DownloadClientItemClientInfo.FromDownloadClient(this); queueItem.DownloadId = sabQueueItem.Id; queueItem.Category = sabQueueItem.Category; queueItem.Title = sabQueueItem.Title; @@ -117,7 +117,7 @@ namespace NzbDrone.Core.Download.Clients.Sabnzbd var historyItem = new DownloadClientItem { - DownloadClient = Definition.Name, + DownloadClientInfo = DownloadClientItemClientInfo.FromDownloadClient(this), DownloadId = sabHistoryItem.Id, Category = sabHistoryItem.Category, Title = sabHistoryItem.Title, diff --git a/src/NzbDrone.Core/Download/Clients/Transmission/TransmissionBase.cs b/src/NzbDrone.Core/Download/Clients/Transmission/TransmissionBase.cs index 07d35d810..081c67f1e 100644 --- a/src/NzbDrone.Core/Download/Clients/Transmission/TransmissionBase.cs +++ b/src/NzbDrone.Core/Download/Clients/Transmission/TransmissionBase.cs @@ -70,7 +70,7 @@ namespace NzbDrone.Core.Download.Clients.Transmission item.Category = Settings.MusicCategory; item.Title = torrent.Name; - item.DownloadClient = Definition.Name; + item.DownloadClientInfo = DownloadClientItemClientInfo.FromDownloadClient(this); item.OutputPath = GetOutputPath(outputPath, torrent); item.TotalSize = torrent.TotalSize; diff --git a/src/NzbDrone.Core/Download/Clients/rTorrent/RTorrent.cs b/src/NzbDrone.Core/Download/Clients/rTorrent/RTorrent.cs index 758e96612..d3bcffb22 100644 --- a/src/NzbDrone.Core/Download/Clients/rTorrent/RTorrent.cs +++ b/src/NzbDrone.Core/Download/Clients/rTorrent/RTorrent.cs @@ -120,7 +120,7 @@ namespace NzbDrone.Core.Download.Clients.RTorrent } var item = new DownloadClientItem(); - item.DownloadClient = Definition.Name; + item.DownloadClientInfo = DownloadClientItemClientInfo.FromDownloadClient(this); item.Title = torrent.Name; item.DownloadId = torrent.Hash; item.OutputPath = _remotePathMappingService.RemapRemoteToLocal(Settings.Host, new OsPath(torrent.Path)); diff --git a/src/NzbDrone.Core/Download/Clients/uTorrent/UTorrent.cs b/src/NzbDrone.Core/Download/Clients/uTorrent/UTorrent.cs index c7c0911e5..ecce4af45 100644 --- a/src/NzbDrone.Core/Download/Clients/uTorrent/UTorrent.cs +++ b/src/NzbDrone.Core/Download/Clients/uTorrent/UTorrent.cs @@ -118,7 +118,7 @@ namespace NzbDrone.Core.Download.Clients.UTorrent item.Title = torrent.Name; item.TotalSize = torrent.Size; item.Category = torrent.Label; - item.DownloadClient = Definition.Name; + item.DownloadClientInfo = DownloadClientItemClientInfo.FromDownloadClient(this); item.RemainingSize = torrent.Remaining; item.SeedRatio = torrent.Ratio; diff --git a/src/NzbDrone.Core/Download/DownloadClientItem.cs b/src/NzbDrone.Core/Download/DownloadClientItem.cs index ef890244c..88b04e0fe 100644 --- a/src/NzbDrone.Core/Download/DownloadClientItem.cs +++ b/src/NzbDrone.Core/Download/DownloadClientItem.cs @@ -2,13 +2,14 @@ using System; using System.Diagnostics; using NzbDrone.Common.Disk; using NzbDrone.Core.Indexers; +using NzbDrone.Core.ThingiProvider; namespace NzbDrone.Core.Download { - [DebuggerDisplay("{DownloadClient}:{Title}")] + [DebuggerDisplay("{DownloadClientName}:{Title}")] public class DownloadClientItem { - public string DownloadClient { get; set; } + public DownloadClientItemClientInfo DownloadClientInfo { get; set; } public string DownloadId { get; set; } public string Category { get; set; } public string Title { get; set; } @@ -17,13 +18,10 @@ namespace NzbDrone.Core.Download public long RemainingSize { get; set; } public TimeSpan? RemainingTime { get; set; } public double? SeedRatio { get; set; } - public OsPath OutputPath { get; set; } public string Message { get; set; } - public DownloadItemStatus Status { get; set; } public bool IsEncrypted { get; set; } - public bool CanMoveFiles { get; set; } public bool CanBeRemoved { get; set; } public bool Removed { get; set; } @@ -41,6 +39,16 @@ namespace NzbDrone.Core.Download public int Id { get; set; } public string Name { get; set; } - public bool Removed { get; set; } + public static DownloadClientItemClientInfo FromDownloadClient(DownloadClientBase downloadClient) + where TSettings : IProviderConfig, new() + { + return new DownloadClientItemClientInfo + { + Protocol = downloadClient.Protocol, + Type = downloadClient.Name, + Id = downloadClient.Definition.Id, + Name = downloadClient.Definition.Name + }; + } } } diff --git a/src/NzbDrone.Core/Download/DownloadEventHub.cs b/src/NzbDrone.Core/Download/DownloadEventHub.cs index e75fdbc1f..ef219a3a0 100644 --- a/src/NzbDrone.Core/Download/DownloadEventHub.cs +++ b/src/NzbDrone.Core/Download/DownloadEventHub.cs @@ -61,7 +61,7 @@ namespace NzbDrone.Core.Download var downloadClient = _downloadClientProvider.Get(trackedDownload.DownloadClient); try { - _logger.Debug("[{0}] Removing download from {1} history", trackedDownload.DownloadItem.Title, trackedDownload.DownloadItem.DownloadClient); + _logger.Debug("[{0}] Removing download from {1} history", trackedDownload.DownloadItem.Title, trackedDownload.DownloadItem.DownloadClientInfo.Name); downloadClient.RemoveItem(trackedDownload.DownloadItem.DownloadId, true); trackedDownload.DownloadItem.Removed = true; } @@ -80,7 +80,7 @@ namespace NzbDrone.Core.Download var downloadClient = _downloadClientProvider.Get(trackedDownload.DownloadClient); try { - _logger.Debug("[{0}] Marking download as imported from {1}", trackedDownload.DownloadItem.Title, trackedDownload.DownloadItem.DownloadClient); + _logger.Debug("[{0}] Marking download as imported from {1}", trackedDownload.DownloadItem.Title, trackedDownload.DownloadItem.DownloadClientInfo.Name); downloadClient.MarkItemAsImported(trackedDownload.DownloadItem); } catch (NotSupportedException e) diff --git a/src/NzbDrone.Core/Download/DownloadIgnoredEvent.cs b/src/NzbDrone.Core/Download/DownloadIgnoredEvent.cs index c8082941a..4a6372506 100644 --- a/src/NzbDrone.Core/Download/DownloadIgnoredEvent.cs +++ b/src/NzbDrone.Core/Download/DownloadIgnoredEvent.cs @@ -10,7 +10,7 @@ namespace NzbDrone.Core.Download public List BookIds { get; set; } public QualityModel Quality { get; set; } public string SourceTitle { get; set; } - public string DownloadClient { get; set; } + public DownloadClientItemClientInfo DownloadClientInfo { get; set; } public string DownloadId { get; set; } public string Message { get; set; } } diff --git a/src/NzbDrone.Core/Download/IgnoredDownloadService.cs b/src/NzbDrone.Core/Download/IgnoredDownloadService.cs index 0479c6e19..f18093b3c 100644 --- a/src/NzbDrone.Core/Download/IgnoredDownloadService.cs +++ b/src/NzbDrone.Core/Download/IgnoredDownloadService.cs @@ -35,15 +35,15 @@ namespace NzbDrone.Core.Download } var downloadIgnoredEvent = new DownloadIgnoredEvent - { - AuthorId = author.Id, - BookIds = books.Select(e => e.Id).ToList(), - Quality = trackedDownload.RemoteBook.ParsedBookInfo.Quality, - SourceTitle = trackedDownload.DownloadItem.Title, - DownloadClient = trackedDownload.DownloadItem.DownloadClient, - DownloadId = trackedDownload.DownloadItem.DownloadId, - Message = "Manually ignored" - }; + { + AuthorId = author.Id, + BookIds = books.Select(e => e.Id).ToList(), + Quality = trackedDownload.RemoteBook.ParsedBookInfo.Quality, + SourceTitle = trackedDownload.DownloadItem.Title, + DownloadClientInfo = trackedDownload.DownloadItem.DownloadClientInfo, + DownloadId = trackedDownload.DownloadItem.DownloadId, + Message = "Manually ignored" + }; _eventAggregator.PublishEvent(downloadIgnoredEvent); return true; diff --git a/src/NzbDrone.Core/Download/TrackedDownloads/TrackedDownloadService.cs b/src/NzbDrone.Core/Download/TrackedDownloads/TrackedDownloadService.cs index 5ed6ac903..3a1f07881 100644 --- a/src/NzbDrone.Core/Download/TrackedDownloads/TrackedDownloadService.cs +++ b/src/NzbDrone.Core/Download/TrackedDownloads/TrackedDownloadService.cs @@ -232,7 +232,7 @@ namespace NzbDrone.Core.Download.TrackedDownloads existingItem.CanMoveFiles != downloadItem.CanMoveFiles) { _logger.Debug("Tracking '{0}:{1}': ClientState={2}{3} ReadarrStage={4} Book='{5}' OutputPath={6}.", - downloadItem.DownloadClient, + downloadItem.DownloadClientInfo.Name, downloadItem.Title, downloadItem.Status, downloadItem.CanBeRemoved ? "" : downloadItem.CanMoveFiles ? " (busy)" : " (readonly)", diff --git a/src/NzbDrone.Core/History/HistoryService.cs b/src/NzbDrone.Core/History/HistoryService.cs index e45c9fe01..9f050d317 100644 --- a/src/NzbDrone.Core/History/HistoryService.cs +++ b/src/NzbDrone.Core/History/HistoryService.cs @@ -369,7 +369,7 @@ namespace NzbDrone.Core.History DownloadId = message.DownloadId }; - history.Data.Add("DownloadClient", message.DownloadClient); + history.Data.Add("DownloadClient", message.DownloadClientInfo.Name); history.Data.Add("Message", message.Message); historyToAdd.Add(history); diff --git a/src/NzbDrone.Core/MediaFiles/Events/BookImportedEvent.cs b/src/NzbDrone.Core/MediaFiles/Events/BookImportedEvent.cs index f67a2de92..200ee7f28 100644 --- a/src/NzbDrone.Core/MediaFiles/Events/BookImportedEvent.cs +++ b/src/NzbDrone.Core/MediaFiles/Events/BookImportedEvent.cs @@ -25,7 +25,7 @@ namespace NzbDrone.Core.MediaFiles.Events if (downloadClientItem != null) { - DownloadClient = downloadClientItem.DownloadClient; + DownloadClient = downloadClientItem.DownloadClientInfo.Name; DownloadId = downloadClientItem.DownloadId; } } diff --git a/src/NzbDrone.Core/MediaFiles/Events/TrackImportFailedEvent.cs b/src/NzbDrone.Core/MediaFiles/Events/TrackImportFailedEvent.cs index 346f054b8..915aa900e 100644 --- a/src/NzbDrone.Core/MediaFiles/Events/TrackImportFailedEvent.cs +++ b/src/NzbDrone.Core/MediaFiles/Events/TrackImportFailedEvent.cs @@ -21,7 +21,7 @@ namespace NzbDrone.Core.MediaFiles.Events if (downloadClientItem != null) { - DownloadClient = downloadClientItem.DownloadClient; + DownloadClient = downloadClientItem.DownloadClientInfo.Name; DownloadId = downloadClientItem.DownloadId; } } diff --git a/src/NzbDrone.Core/MediaFiles/Events/TrackImportedEvent.cs b/src/NzbDrone.Core/MediaFiles/Events/TrackImportedEvent.cs index 5f7e039d9..f3801eaaa 100644 --- a/src/NzbDrone.Core/MediaFiles/Events/TrackImportedEvent.cs +++ b/src/NzbDrone.Core/MediaFiles/Events/TrackImportedEvent.cs @@ -23,7 +23,7 @@ namespace NzbDrone.Core.MediaFiles.Events if (downloadClientItem != null) { - DownloadClient = downloadClientItem.DownloadClient; + DownloadClient = downloadClientItem.DownloadClientInfo.Name; DownloadId = downloadClientItem.DownloadId; } } diff --git a/src/NzbDrone.Core/Queue/QueueService.cs b/src/NzbDrone.Core/Queue/QueueService.cs index 95007fdbd..adbb245e1 100644 --- a/src/NzbDrone.Core/Queue/QueueService.cs +++ b/src/NzbDrone.Core/Queue/QueueService.cs @@ -86,7 +86,7 @@ namespace NzbDrone.Core.Queue RemoteBook = trackedDownload.RemoteBook, DownloadId = trackedDownload.DownloadItem.DownloadId, Protocol = trackedDownload.Protocol, - DownloadClient = trackedDownload.DownloadItem.DownloadClient, + DownloadClient = trackedDownload.DownloadItem.DownloadClientInfo.Name, Indexer = trackedDownload.Indexer, OutputPath = trackedDownload.DownloadItem.OutputPath.ToString(), DownloadForced = downloadForced