From e9dfdab907d480beb1d1a8ed3dff8e8d66406996 Mon Sep 17 00:00:00 2001 From: Qstick Date: Sat, 4 May 2019 23:10:13 -0400 Subject: [PATCH] New: Use NZBget's FinalDir if set by post-processing script --- .../NzbgetTests/NzbgetFixture.cs | 31 +++++++++++++++++++ .../Download/Clients/Nzbget/Nzbget.cs | 5 +-- .../Clients/Nzbget/NzbgetHistoryItem.cs | 3 +- 3 files changed, 36 insertions(+), 3 deletions(-) diff --git a/src/NzbDrone.Core.Test/Download/DownloadClientTests/NzbgetTests/NzbgetFixture.cs b/src/NzbDrone.Core.Test/Download/DownloadClientTests/NzbgetTests/NzbgetFixture.cs index bb0c75c7b..66b7db64d 100644 --- a/src/NzbDrone.Core.Test/Download/DownloadClientTests/NzbgetTests/NzbgetFixture.cs +++ b/src/NzbDrone.Core.Test/Download/DownloadClientTests/NzbgetTests/NzbgetFixture.cs @@ -405,6 +405,37 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.NzbgetTests result.OutputPath.Should().Be(@"O:\mymount\Fall Out Boy-Make America Psycho Again-CD-FLAC-2015-FORSAKEN".AsOsAgnostic()); } + [Test] + public void should_use_dest_dir_if_final_dir_is_null() + { + GivenQueue(null); + GivenHistory(_completed); + + Subject.GetItems().First().OutputPath.Should().Be(_completed.DestDir); + } + + [Test] + public void should_use_dest_dir_if_final_dir_is_not_set() + { + _completed.FinalDir = string.Empty; + + GivenQueue(null); + GivenHistory(_completed); + + Subject.GetItems().First().OutputPath.Should().Be(_completed.DestDir); + } + + [Test] + public void should_use_final_dir_when_set_instead_of_dest_dir() + { + _completed.FinalDir = "/remote/mount/music2/Some.Artist-Some.Album.FLAC.2018-DRONE"; + + GivenQueue(null); + GivenHistory(_completed); + + Subject.GetItems().First().OutputPath.Should().Be(_completed.FinalDir); + } + [TestCase("11.0", false)] [TestCase("12.0", true)] [TestCase("11.0-b30ef0134", false)] diff --git a/src/NzbDrone.Core/Download/Clients/Nzbget/Nzbget.cs b/src/NzbDrone.Core/Download/Clients/Nzbget/Nzbget.cs index 9c5a205f3..c1c9822e2 100644 --- a/src/NzbDrone.Core/Download/Clients/Nzbget/Nzbget.cs +++ b/src/NzbDrone.Core/Download/Clients/Nzbget/Nzbget.cs @@ -117,13 +117,14 @@ namespace NzbDrone.Core.Download.Clients.Nzbget foreach (var item in history) { var droneParameter = item.Parameters.SingleOrDefault(p => p.Name == "drone"); - var historyItem = new DownloadClientItem(); + var itemDir = item.FinalDir.IsNullOrWhiteSpace() ? item.DestDir : item.FinalDir; + historyItem.DownloadClient = Definition.Name; historyItem.DownloadId = droneParameter == null ? item.Id.ToString() : droneParameter.Value.ToString(); historyItem.Title = item.Name; historyItem.TotalSize = MakeInt64(item.FileSizeHi, item.FileSizeLo); - historyItem.OutputPath = _remotePathMappingService.RemapRemoteToLocal(Settings.Host, new OsPath(item.DestDir)); + historyItem.OutputPath = _remotePathMappingService.RemapRemoteToLocal(Settings.Host, new OsPath(itemDir)); historyItem.Category = item.Category; historyItem.Message = $"PAR Status: {item.ParStatus} - Unpack Status: {item.UnpackStatus} - Move Status: {item.MoveStatus} - Script Status: {item.ScriptStatus} - Delete Status: {item.DeleteStatus} - Mark Status: {item.MarkStatus}"; historyItem.Status = DownloadItemStatus.Completed; diff --git a/src/NzbDrone.Core/Download/Clients/Nzbget/NzbgetHistoryItem.cs b/src/NzbDrone.Core/Download/Clients/Nzbget/NzbgetHistoryItem.cs index b36885cf9..a108f5176 100644 --- a/src/NzbDrone.Core/Download/Clients/Nzbget/NzbgetHistoryItem.cs +++ b/src/NzbDrone.Core/Download/Clients/Nzbget/NzbgetHistoryItem.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; namespace NzbDrone.Core.Download.Clients.Nzbget { @@ -16,6 +16,7 @@ namespace NzbDrone.Core.Download.Clients.Nzbget public string DeleteStatus { get; set; } public string MarkStatus { get; set; } public string DestDir { get; set; } + public string FinalDir { get; set; } public List Parameters { get; set; } } }