diff --git a/src/NzbDrone.Core/Extras/ExistingExtraFileService.cs b/src/NzbDrone.Core/Extras/ExistingExtraFileService.cs index 3cc759c40..ecc10d88f 100644 --- a/src/NzbDrone.Core/Extras/ExistingExtraFileService.cs +++ b/src/NzbDrone.Core/Extras/ExistingExtraFileService.cs @@ -10,7 +10,7 @@ namespace NzbDrone.Core.Extras { public interface IExistingExtraFiles { - List ImportExtraFiles(Movie movie, List possibleExtraFiles); + List ImportExtraFiles(Movie movie, List possibleExtraFiles, bool keepExistingEntries); } public class ExistingExtraFileService : IExistingExtraFiles, IHandle @@ -25,7 +25,7 @@ public ExistingExtraFileService(IEnumerable existingE _logger = logger; } - public List ImportExtraFiles(Movie movie, List possibleExtraFiles) + public List ImportExtraFiles(Movie movie, List possibleExtraFiles, bool keepExistingEntries) { _logger.Debug("Looking for existing extra files in {0}", movie.Path); @@ -33,7 +33,7 @@ public List ImportExtraFiles(Movie movie, List possibleExtraFile foreach (var existingExtraFileImporter in _existingExtraFileImporters) { - var imported = existingExtraFileImporter.ProcessFiles(movie, possibleExtraFiles, importedFiles); + var imported = existingExtraFileImporter.ProcessFiles(movie, possibleExtraFiles, importedFiles, keepExistingEntries); importedFiles.AddRange(imported.Select(f => Path.Combine(movie.Path, f.RelativePath))); } @@ -45,7 +45,7 @@ public void Handle(MovieScannedEvent message) { var movie = message.Movie; var possibleExtraFiles = message.PossibleExtraFiles; - var importedFiles = ImportExtraFiles(movie, possibleExtraFiles); + var importedFiles = ImportExtraFiles(movie, possibleExtraFiles, false); _logger.Info("Found {0} possible extra files, imported {1} files.", possibleExtraFiles.Count, importedFiles.Count); } diff --git a/src/NzbDrone.Core/Extras/IImportExistingExtraFiles.cs b/src/NzbDrone.Core/Extras/IImportExistingExtraFiles.cs index b81a8bb90..be64af03c 100644 --- a/src/NzbDrone.Core/Extras/IImportExistingExtraFiles.cs +++ b/src/NzbDrone.Core/Extras/IImportExistingExtraFiles.cs @@ -7,6 +7,6 @@ namespace NzbDrone.Core.Extras public interface IImportExistingExtraFiles { int Order { get; } - IEnumerable ProcessFiles(Movie movie, List filesOnDisk, List importedFiles); + IEnumerable ProcessFiles(Movie movie, List filesOnDisk, List importedFiles, bool keepExistingEntries); } } diff --git a/src/NzbDrone.Core/Extras/ImportExistingExtraFilesBase.cs b/src/NzbDrone.Core/Extras/ImportExistingExtraFilesBase.cs index d5fc47936..f4683ed1a 100644 --- a/src/NzbDrone.Core/Extras/ImportExistingExtraFilesBase.cs +++ b/src/NzbDrone.Core/Extras/ImportExistingExtraFilesBase.cs @@ -19,10 +19,15 @@ public ImportExistingExtraFilesBase(IExtraFileService extraFileServi } public abstract int Order { get; } - public abstract IEnumerable ProcessFiles(Movie movie, List filesOnDisk, List importedFiles); + public abstract IEnumerable ProcessFiles(Movie movie, List filesOnDisk, List importedFiles, bool keepExistingEntries); - public virtual ImportExistingExtraFileFilterResult FilterAndClean(Movie movie, List filesOnDisk, List importedFiles) + public virtual ImportExistingExtraFileFilterResult FilterAndClean(Movie movie, List filesOnDisk, List importedFiles, bool keepExistingEntries) { + if (keepExistingEntries) + { + return Filter(movie, filesOnDisk, importedFiles, new List()); + } + var movieFiles = _extraFileService.GetFilesByMovie(movie.Id); Clean(movie, filesOnDisk, importedFiles, movieFiles); diff --git a/src/NzbDrone.Core/Extras/Metadata/ExistingMetadataImporter.cs b/src/NzbDrone.Core/Extras/Metadata/ExistingMetadataImporter.cs index ec9b28d07..dd3795c02 100644 --- a/src/NzbDrone.Core/Extras/Metadata/ExistingMetadataImporter.cs +++ b/src/NzbDrone.Core/Extras/Metadata/ExistingMetadataImporter.cs @@ -31,12 +31,12 @@ public ExistingMetadataImporter(IExtraFileService metadataFileServ public override int Order => 0; - public override IEnumerable ProcessFiles(Movie movie, List filesOnDisk, List importedFiles) + public override IEnumerable ProcessFiles(Movie movie, List filesOnDisk, List importedFiles, bool keepExistingEntries) { _logger.Debug("Looking for existing metadata in {0}", movie.Path); var metadataFiles = new List(); - var filterResult = FilterAndClean(movie, filesOnDisk, importedFiles); + var filterResult = FilterAndClean(movie, filesOnDisk, importedFiles, keepExistingEntries); foreach (var possibleMetadataFile in filterResult.FilesOnDisk) { diff --git a/src/NzbDrone.Core/Extras/Others/ExistingOtherExtraImporter.cs b/src/NzbDrone.Core/Extras/Others/ExistingOtherExtraImporter.cs index a30f9fa17..6a440f43c 100644 --- a/src/NzbDrone.Core/Extras/Others/ExistingOtherExtraImporter.cs +++ b/src/NzbDrone.Core/Extras/Others/ExistingOtherExtraImporter.cs @@ -27,12 +27,12 @@ public ExistingOtherExtraImporter(IExtraFileService otherExtraFi public override int Order => 2; - public override IEnumerable ProcessFiles(Movie movie, List filesOnDisk, List importedFiles) + public override IEnumerable ProcessFiles(Movie movie, List filesOnDisk, List importedFiles, bool keepExistingEntries) { _logger.Debug("Looking for existing extra files in {0}", movie.Path); var extraFiles = new List(); - var filterResult = FilterAndClean(movie, filesOnDisk, importedFiles); + var filterResult = FilterAndClean(movie, filesOnDisk, importedFiles, keepExistingEntries); foreach (var possibleExtraFile in filterResult.FilesOnDisk) { diff --git a/src/NzbDrone.Core/Extras/Subtitles/ExistingSubtitleImporter.cs b/src/NzbDrone.Core/Extras/Subtitles/ExistingSubtitleImporter.cs index 66597eb91..a8062130b 100644 --- a/src/NzbDrone.Core/Extras/Subtitles/ExistingSubtitleImporter.cs +++ b/src/NzbDrone.Core/Extras/Subtitles/ExistingSubtitleImporter.cs @@ -32,12 +32,12 @@ public ExistingSubtitleImporter(IExtraFileService subtitleFileServ public override int Order => 1; - public override IEnumerable ProcessFiles(Movie movie, List filesOnDisk, List importedFiles) + public override IEnumerable ProcessFiles(Movie movie, List filesOnDisk, List importedFiles, bool keepExistingEntries) { _logger.Debug("Looking for existing subtitle files in {0}", movie.Path); var subtitleFiles = new List(); - var filterResult = FilterAndClean(movie, filesOnDisk, importedFiles); + var filterResult = FilterAndClean(movie, filesOnDisk, importedFiles, keepExistingEntries); foreach (var possibleSubtitleFile in filterResult.FilesOnDisk) { diff --git a/src/NzbDrone.Core/MediaFiles/MovieImport/ImportApprovedMovie.cs b/src/NzbDrone.Core/MediaFiles/MovieImport/ImportApprovedMovie.cs index ef25f2197..e0dd83886 100644 --- a/src/NzbDrone.Core/MediaFiles/MovieImport/ImportApprovedMovie.cs +++ b/src/NzbDrone.Core/MediaFiles/MovieImport/ImportApprovedMovie.cs @@ -155,7 +155,7 @@ public List Import(List decisions, bool newDownloa { if (localMovie.ScriptImported) { - _existingExtraFiles.ImportExtraFiles(localMovie.Movie, localMovie.PossibleExtraFiles); + _existingExtraFiles.ImportExtraFiles(localMovie.Movie, localMovie.PossibleExtraFiles, true); if (localMovie.FileRenamedAfterScriptImport) {