1
0
Fork 0
mirror of https://github.com/Radarr/Radarr synced 2025-01-19 14:11:40 +00:00

Ignore Deleted Movies (#755) (#879)

This commit is contained in:
Devin Buhl 2017-02-24 21:30:12 -05:00 committed by GitHub
parent ca164c2a24
commit 816c62979a

View file

@ -13,6 +13,7 @@
using NzbDrone.Core.MediaFiles;
using NzbDrone.Core.MediaFiles.Events;
using NzbDrone.Core.Datastore;
using NzbDrone.Core.Configuration;
namespace NzbDrone.Core.Tv
{
@ -46,6 +47,7 @@ public class MovieService : IMovieService, IHandle<MovieFileAddedEvent>,
IHandle<MovieFileDeletedEvent>
{
private readonly IMovieRepository _movieRepository;
private readonly IConfigService _configService;
private readonly IEventAggregator _eventAggregator;
private readonly IBuildFileNames _fileNameBuilder;
private readonly Logger _logger;
@ -55,11 +57,13 @@ public MovieService(IMovieRepository movieRepository,
ISceneMappingService sceneMappingService,
IEpisodeService episodeService,
IBuildFileNames fileNameBuilder,
IConfigService configService,
Logger logger)
{
_movieRepository = movieRepository;
_eventAggregator = eventAggregator;
_fileNameBuilder = fileNameBuilder;
_configService = configService;
_logger = logger;
}
@ -297,8 +301,15 @@ public void Handle(MovieFileAddedEvent message)
public void Handle(MovieFileDeletedEvent message)
{
var movie = _movieRepository.GetMoviesByFileId(message.MovieFile.Id).First();
movie.MovieFileId = 0;
_logger.Debug("Detaching movie {0} from file.", movie.Id);
if (message.Reason != DeleteMediaFileReason.Upgrade && _configService.AutoUnmonitorPreviouslyDownloadedEpisodes)
{
movie.Monitored = false;
}
UpdateMovie(movie);
}