From a9ee3d5bc50ba704ac3da3b94a79c8e88168e883 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Wed, 6 Feb 2019 19:26:27 -0800 Subject: [PATCH] Fixed: Importing completed downloads from NZBGet with post processing script failing Fixes #2919 --- .../MediaFiles/ImportApprovedMoviesFixture.cs | 15 +++++++++++++++ .../MediaFiles/MovieImport/ImportApprovedMovie.cs | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/NzbDrone.Core.Test/MediaFiles/ImportApprovedMoviesFixture.cs b/src/NzbDrone.Core.Test/MediaFiles/ImportApprovedMoviesFixture.cs index b2ecbd004..d55ac2c13 100644 --- a/src/NzbDrone.Core.Test/MediaFiles/ImportApprovedMoviesFixture.cs +++ b/src/NzbDrone.Core.Test/MediaFiles/ImportApprovedMoviesFixture.cs @@ -380,5 +380,20 @@ public void should_use_folder_info_original_title_to_find_relative_path_when_fil Mocker.GetMock().Verify(v => v.Add(It.Is(c => c.OriginalFilePath == $"subfolder\\{name}.mkv".AsOsAgnostic()))); } + + [Test] + public void should_use_folder_info_original_title_to_find_relative_path_when_download_client_item_has_an_empty_output_path() + { + var name = "Transformers.2007.720p.BluRay.x264-Radarr"; + var outputPath = Path.Combine(@"C:\Test\Unsorted\movies\".AsOsAgnostic(), name); + var localMovie = _approvedDecisions.First().LocalMovie; + + localMovie.FolderMovieInfo = new ParsedMovieInfo { ReleaseTitle = name }; + localMovie.Path = Path.Combine(outputPath, "subfolder", name + ".mkv"); + + Subject.Import(new List { _approvedDecisions.First() }, true, _downloadClientItem); + + Mocker.GetMock().Verify(v => v.Add(It.Is(c => c.OriginalFilePath == $"subfolder\\{name}.mkv".AsOsAgnostic()))); + } } } diff --git a/src/NzbDrone.Core/MediaFiles/MovieImport/ImportApprovedMovie.cs b/src/NzbDrone.Core/MediaFiles/MovieImport/ImportApprovedMovie.cs index fb608b6a1..1078f92d9 100644 --- a/src/NzbDrone.Core/MediaFiles/MovieImport/ImportApprovedMovie.cs +++ b/src/NzbDrone.Core/MediaFiles/MovieImport/ImportApprovedMovie.cs @@ -180,7 +180,7 @@ private string GetOriginalFilePath(DownloadClientItem downloadClientItem, LocalM { var path = localMovie.Path; - if (downloadClientItem != null) + if (downloadClientItem != null && !downloadClientItem.OutputPath.IsEmpty) { var outputDirectory = downloadClientItem.OutputPath.Directory.ToString();