Fixed: Don't blow up on batch list add if validation failure

pull/4798/head
Qstick 4 years ago
parent df75027e3c
commit bd9a93eceb

@ -15,7 +15,7 @@ namespace NzbDrone.Core.Movies
public interface IAddMovieService public interface IAddMovieService
{ {
Movie AddMovie(Movie newMovie); Movie AddMovie(Movie newMovie);
List<Movie> AddMovies(List<Movie> newMovies); List<Movie> AddMovies(List<Movie> newMovies, bool ignoreErrors = false);
} }
public class AddMovieService : IAddMovieService public class AddMovieService : IAddMovieService
@ -52,7 +52,7 @@ namespace NzbDrone.Core.Movies
return newMovie; return newMovie;
} }
public List<Movie> AddMovies(List<Movie> newMovies) public List<Movie> AddMovies(List<Movie> newMovies, bool ignoreErrors = false)
{ {
var added = DateTime.UtcNow; var added = DateTime.UtcNow;
var moviesToAdd = new List<Movie>(); var moviesToAdd = new List<Movie>();
@ -60,10 +60,22 @@ namespace NzbDrone.Core.Movies
foreach (var m in newMovies) foreach (var m in newMovies)
{ {
// TODO: Verify if adding skyhook data will be slow // TODO: Verify if adding skyhook data will be slow
var movie = AddSkyhookData(m); try
movie = SetPropertiesAndValidate(movie); {
movie.Added = added; var movie = AddSkyhookData(m);
moviesToAdd.Add(movie); 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); return _movieService.AddMovies(moviesToAdd);

@ -154,7 +154,7 @@ namespace NzbDrone.Core.NetImport
_logger.Info($"Adding {moviesToAdd.Count()} movies from your auto enabled lists to library"); _logger.Info($"Adding {moviesToAdd.Count()} movies from your auto enabled lists to library");
} }
_addMovieService.AddMovies(moviesToAdd); _addMovieService.AddMovies(moviesToAdd, true);
} }
private void CleanLibrary(List<Movie> movies) private void CleanLibrary(List<Movie> movies)

Loading…
Cancel
Save