Fixed: Importing of completed download when not a child of the download client output path

pull/2/head
Mark McDowall 6 years ago committed by ta264
parent 92a0305740
commit 1dfe6eb6ed

@ -364,5 +364,21 @@ namespace NzbDrone.Core.Test.MediaFiles
Mocker.GetMock<IMediaFileService>().Verify(v => v.Add(It.Is<MovieFile>(c => c.OriginalFilePath == $"{name}.mkv")));
}
[Test]
public void should_use_folder_info_original_title_to_find_relative_path_when_file_is_not_in_download_client_item_output_directory()
{
var name = "Transformers.2007.720p.BluRay.x264-Radarr";
var outputPath = Path.Combine(@"C:\Test\Unsorted\movie\".AsOsAgnostic(), name);
var localMovie = _approvedDecisions.First().LocalMovie;
_downloadClientItem.OutputPath = new OsPath(Path.Combine(@"C:\Test\Unsorted\movie-Other\".AsOsAgnostic(), name));
localMovie.FolderMovieInfo = new ParsedMovieInfo { ReleaseTitle = name };
localMovie.Path = Path.Combine(outputPath, "subfolder", name + ".mkv");
Subject.Import(new List<ImportDecision> { _approvedDecisions.First() }, true, _downloadClientItem);
Mocker.GetMock<IMediaFileService>().Verify(v => v.Add(It.Is<MovieFile>(c => c.OriginalFilePath == $"subfolder\\{name}.mkv".AsOsAgnostic())));
}
}
}

@ -178,12 +178,18 @@ namespace NzbDrone.Core.MediaFiles.MovieImport
private string GetOriginalFilePath(DownloadClientItem downloadClientItem, LocalMovie localMovie)
{
var path = localMovie.Path;
if (downloadClientItem != null)
{
return downloadClientItem.OutputPath.Directory.ToString().GetRelativePath(localMovie.Path);
var outputDirectory = downloadClientItem.OutputPath.Directory.ToString();
if (outputDirectory.IsParentPath(path))
{
return outputDirectory.GetRelativePath(path);
}
}
var path = localMovie.Path;
var folderMovieInfo = localMovie.FolderMovieInfo;
if (folderMovieInfo != null)

Loading…
Cancel
Save