mirror of
https://github.com/Radarr/Radarr.git
synced 2024-09-11 20:12:41 +02:00
Fixed: Don't blow up on batch list add if validation failure
This commit is contained in:
parent
df75027e3c
commit
bd9a93eceb
@ -15,7 +15,7 @@ namespace NzbDrone.Core.Movies
|
||||
public interface IAddMovieService
|
||||
{
|
||||
Movie AddMovie(Movie newMovie);
|
||||
List<Movie> AddMovies(List<Movie> newMovies);
|
||||
List<Movie> AddMovies(List<Movie> newMovies, bool ignoreErrors = false);
|
||||
}
|
||||
|
||||
public class AddMovieService : IAddMovieService
|
||||
@ -52,7 +52,7 @@ public Movie AddMovie(Movie 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 moviesToAdd = new List<Movie>();
|
||||
@ -60,10 +60,22 @@ public List<Movie> AddMovies(List<Movie> 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);
|
||||
|
@ -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<Movie> movies)
|
||||
|
Loading…
Reference in New Issue
Block a user