Example #1
0
        public void HandleAsync(MovieFileDeletedEvent message)
        {
            var movieFile = message.MovieFile;

            if (message.Reason == DeleteMediaFileReason.NoLinkedEpisodes)
            {
                _logger.Debug("Removing movie file from DB as part of cleanup routine, not deleting extra files from disk.");
            }

            else
            {
                var movie = _movieService.GetMovie(message.MovieFile.MovieId);

                foreach (var extra in _repository.GetFilesByMovieFile(movieFile.Id))
                {
                    var path = Path.Combine(movie.Path, extra.RelativePath);

                    if (_diskProvider.FileExists(path))
                    {
                        // Send to the recycling bin so they can be recovered if necessary
                        _recycleBinProvider.DeleteFile(path);
                    }
                }
            }

            _logger.Debug("Deleting Extra from database for movie file: {0}", movieFile);
            _repository.DeleteForMovieFile(movieFile.Id);
        }
Example #2
0
        public void Handle(MovieFileDeletedEvent message)
        {
            var deleteMessage = new MovieFileDeleteMessage();

            deleteMessage.Message   = GetMessage(message.MovieFile.Movie, message.MovieFile.Quality);
            deleteMessage.MovieFile = message.MovieFile;
            deleteMessage.Movie     = message.MovieFile.Movie;
            deleteMessage.Reason    = message.Reason;

            foreach (var notification in _notificationFactory.OnMovieFileDeleteEnabled())
            {
                try
                {
                    if (message.Reason != MediaFiles.DeleteMediaFileReason.Upgrade || ((NotificationDefinition)notification.Definition).OnMovieFileDeleteForUpgrade)
                    {
                        if (ShouldHandleMovie(notification.Definition, message.MovieFile.Movie))
                        {
                            notification.OnMovieFileDelete(deleteMessage);
                        }
                    }
                }
                catch (Exception ex)
                {
                    _logger.Warn(ex, "Unable to send OnMovieFileDelete notification to: " + notification.Definition.Name);
                }
            }
        }
        public void Handle(MovieFileDeletedEvent message)
        {
            if (_configService.DeleteEmptyFolders)
            {
                var movie     = message.MovieFile.Movie;
                var moviePath = movie.Path;
                var folder    = message.MovieFile.Path.GetParentPath();

                while (moviePath.IsParentPath(folder))
                {
                    if (_diskProvider.FolderExists(folder))
                    {
                        _diskProvider.RemoveEmptySubfolders(folder);
                    }

                    folder = folder.GetParentPath();
                }

                _diskProvider.RemoveEmptySubfolders(moviePath);

                if (_diskProvider.FolderEmpty(moviePath))
                {
                    _diskProvider.DeleteFolder(moviePath, true);
                }
            }
        }
Example #4
0
        public void Handle(MovieFileDeletedEvent message)
        {
            if (message.Reason == DeleteMediaFileReason.Upgrade)
            {
                return;
            }

            BroadcastResourceChange(ModelAction.Updated, message.MovieFile.MovieId);
        }
Example #5
0
        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);
        }
Example #6
0
        public void Handle(MovieFileDeletedEvent message)
        {
            if (message.Reason == DeleteMediaFileReason.NoLinkedEpisodes)
            {
                _logger.Debug("Removing movie file from DB as part of cleanup routine, not creating history event.");
                return;
            }

            var history = new History
            {
                EventType   = HistoryEventType.MovieFileDeleted,
                Date        = DateTime.UtcNow,
                Quality     = message.MovieFile.Quality,
                SourceTitle = message.MovieFile.Path,
                MovieId     = message.MovieFile.MovieId
            };

            history.Data.Add("Reason", message.Reason.ToString());

            _historyRepository.Insert(history);
        }
 public void Handle(MovieFileDeletedEvent message)
 {
     BroadcastResourceChange(ModelAction.Deleted, message.MovieFile.Id);
 }