From bd9a93eceb6bd2098b1195a9907c34018e8ffac9 Mon Sep 17 00:00:00 2001 From: Qstick Date: Sat, 1 Aug 2020 23:32:23 -0400 Subject: [PATCH] Fixed: Don't blow up on batch list add if validation failure --- src/NzbDrone.Core/Movies/AddMovieService.cs | 24 ++++++++++++++----- .../NetImport/NetImportSearchService.cs | 2 +- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/NzbDrone.Core/Movies/AddMovieService.cs b/src/NzbDrone.Core/Movies/AddMovieService.cs index 1316245fe..c899120a6 100644 --- a/src/NzbDrone.Core/Movies/AddMovieService.cs +++ b/src/NzbDrone.Core/Movies/AddMovieService.cs @@ -15,7 +15,7 @@ namespace NzbDrone.Core.Movies public interface IAddMovieService { Movie AddMovie(Movie newMovie); - List AddMovies(List newMovies); + List AddMovies(List newMovies, bool ignoreErrors = false); } public class AddMovieService : IAddMovieService @@ -52,7 +52,7 @@ public Movie AddMovie(Movie newMovie) return newMovie; } - public List AddMovies(List newMovies) + public List AddMovies(List newMovies, bool ignoreErrors = false) { var added = DateTime.UtcNow; var moviesToAdd = new List(); @@ -60,10 +60,22 @@ public List AddMovies(List newMovies) foreach (var m in newMovies) { // TODO: Verify if adding skyhook data will be slow - var movie = AddSkyhookData(m); - movie = SetPropertiesAndValidate(movie); - movie.Added = added; - moviesToAdd.Add(movie); + try + { + var movie = AddSkyhookData(m); + movie = SetPropertiesAndValidate(movie); + movie.Added = added; + moviesToAdd.Add(movie); + } + catch (ValidationException ex) + { + if (!ignoreErrors) + { + throw; + } + + _logger.Debug("TmdbId {0} was not added due to validation failures. {1}", m.TmdbId, ex.Message); + } } return _movieService.AddMovies(moviesToAdd); diff --git a/src/NzbDrone.Core/NetImport/NetImportSearchService.cs b/src/NzbDrone.Core/NetImport/NetImportSearchService.cs index 9dcc0cba2..ba5a48d3b 100644 --- a/src/NzbDrone.Core/NetImport/NetImportSearchService.cs +++ b/src/NzbDrone.Core/NetImport/NetImportSearchService.cs @@ -154,7 +154,7 @@ public void Execute(NetImportSyncCommand message) _logger.Info($"Adding {moviesToAdd.Count()} movies from your auto enabled lists to library"); } - _addMovieService.AddMovies(moviesToAdd); + _addMovieService.AddMovies(moviesToAdd, true); } private void CleanLibrary(List movies)