mirror of
https://github.com/Radarr/Radarr.git
synced 2024-10-26 22:52:40 +02:00
Fix cleaning library in ImportListSyncService
This commit is contained in:
parent
1c26dd4aca
commit
5c46c75ce7
@ -50,7 +50,7 @@ public List<ImportListMovie> SyncMoviesForList(List<ImportListMovie> listMovies,
|
||||
|
||||
_importListMovieRepository.InsertMany(listMovies.Where(l => l.Id == 0).ToList());
|
||||
_importListMovieRepository.UpdateMany(listMovies.Where(l => l.Id > 0).ToList());
|
||||
_importListMovieRepository.DeleteMany(existingListMovies.Where(l => !listMovies.Any(x => x.TmdbId == l.TmdbId)).ToList());
|
||||
_importListMovieRepository.DeleteMany(existingListMovies.Where(l => listMovies.All(x => x.TmdbId != l.TmdbId)).ToList());
|
||||
|
||||
return listMovies;
|
||||
}
|
||||
|
@ -20,6 +20,7 @@ public class ImportListSyncService : IExecute<ImportListSyncCommand>
|
||||
private readonly IAddMovieService _addMovieService;
|
||||
private readonly IConfigService _configService;
|
||||
private readonly IImportExclusionsService _exclusionService;
|
||||
private readonly IImportListMovieService _listMovieService;
|
||||
|
||||
public ImportListSyncService(IImportListFactory importListFactory,
|
||||
IFetchAndParseImportList listFetcherAndParser,
|
||||
@ -27,6 +28,7 @@ public ImportListSyncService(IImportListFactory importListFactory,
|
||||
IAddMovieService addMovieService,
|
||||
IConfigService configService,
|
||||
IImportExclusionsService exclusionService,
|
||||
IImportListMovieService listMovieService,
|
||||
Logger logger)
|
||||
{
|
||||
_importListFactory = importListFactory;
|
||||
@ -34,6 +36,7 @@ public ImportListSyncService(IImportListFactory importListFactory,
|
||||
_movieService = movieService;
|
||||
_addMovieService = addMovieService;
|
||||
_exclusionService = exclusionService;
|
||||
_listMovieService = listMovieService;
|
||||
_logger = logger;
|
||||
_configService = configService;
|
||||
}
|
||||
@ -57,10 +60,11 @@ private void SyncAll()
|
||||
return;
|
||||
}
|
||||
|
||||
// if (!result.AnyFailure)
|
||||
// {
|
||||
// CleanLibrary(result.Movies.ToList());
|
||||
// }
|
||||
if (!result.AnyFailure)
|
||||
{
|
||||
CleanLibrary();
|
||||
}
|
||||
|
||||
ProcessReports(result);
|
||||
}
|
||||
|
||||
@ -79,7 +83,7 @@ private void ProcessMovieReport(ImportListDefinition importList, ImportListMovie
|
||||
}
|
||||
|
||||
// Check to see if movie excluded
|
||||
var excludedMovie = listExclusions.Where(s => s.TmdbId == report.TmdbId).SingleOrDefault();
|
||||
var excludedMovie = listExclusions.SingleOrDefault(s => s.TmdbId == report.TmdbId);
|
||||
|
||||
if (excludedMovie != null)
|
||||
{
|
||||
@ -171,17 +175,20 @@ public void Execute(ImportListSyncCommand message)
|
||||
}
|
||||
}
|
||||
|
||||
private void CleanLibrary(List<ImportListMovie> listMovies)
|
||||
private void CleanLibrary()
|
||||
{
|
||||
var moviesToUpdate = new List<Movie>();
|
||||
|
||||
if (_configService.ListSyncLevel == "disabled")
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var listMovies = _listMovieService.GetAllListMovies();
|
||||
|
||||
// TODO use AllMovieTmdbIds here?
|
||||
var moviesInLibrary = _movieService.GetAllMovies();
|
||||
|
||||
var moviesToUpdate = new List<Movie>();
|
||||
|
||||
foreach (var movie in moviesInLibrary)
|
||||
{
|
||||
var movieExists = listMovies.Any(c => c.TmdbId == movie.TmdbId || c.ImdbId == movie.ImdbId);
|
||||
@ -206,8 +213,6 @@ private void CleanLibrary(List<ImportListMovie> listMovies)
|
||||
_logger.Info("{0} was in your library, but not found in your lists --> Removing from library and deleting files", movie);
|
||||
_movieService.DeleteMovie(movie.Id, true);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user