예제 #1
0
        public void Handle(TrackFileDeletedEvent message)
        {
            if (message.Reason == DeleteMediaFileReason.NoLinkedEpisodes)
            {
                _logger.Debug("Removing track file from DB as part of cleanup routine, not creating history event.");
                return;
            }
            else if (message.Reason == DeleteMediaFileReason.ManualOverride)
            {
                _logger.Debug("Removing track file from DB as part of manual override of existing file, not creating history event.");
                return;
            }

            foreach (var track in message.TrackFile.Tracks.Value)
            {
                var history = new History
                {
                    EventType   = HistoryEventType.TrackFileDeleted,
                    Date        = DateTime.UtcNow,
                    Quality     = message.TrackFile.Quality,
                    SourceTitle = message.TrackFile.Path,
                    ArtistId    = message.TrackFile.Artist.Value.Id,
                    AlbumId     = message.TrackFile.AlbumId,
                    TrackId     = track.Id,
                };

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

                _historyRepository.Insert(history);
            }
        }
예제 #2
0
        public void Handle(TrackFileDeletedEvent message)
        {
            var trackFile = message.TrackFile;

            if (message.Reason == DeleteMediaFileReason.NoLinkedEpisodes)
            {
                _logger.Debug("Removing track file from DB as part of cleanup routine, not deleting extra files from disk.");
            }
            else
            {
                var artist = trackFile.Artist.Value;

                foreach (var extra in _repository.GetFilesByTrackFile(trackFile.Id))
                {
                    var path = Path.Combine(artist.Path, extra.RelativePath);

                    if (_diskProvider.FileExists(path))
                    {
                        // Send to the recycling bin so they can be recovered if necessary
                        var subfolder = _diskProvider.GetParentFolder(artist.Path).GetRelativePath(_diskProvider.GetParentFolder(path));
                        _recycleBinProvider.DeleteFile(path, subfolder);
                    }
                }
            }

            _logger.Debug("Deleting Extra from database for track file: {0}", trackFile);
            _repository.DeleteForTrackFile(trackFile.Id);
        }
예제 #3
0
 public void Handle(TrackFileDeletedEvent message)
 {
     foreach (var track in message.TrackFile.Tracks.Value)
     {
         track.TrackFile = message.TrackFile;
         BroadcastResourceChange(ModelAction.Updated, MapToResource(track, true, true));
     }
 }
예제 #4
0
        public void Handle(TrackFileDeletedEvent message)
        {
            if (message.Reason == DeleteMediaFileReason.Upgrade)
            {
                return;
            }

            BroadcastResourceChange(ModelAction.Updated, GetArtistResource(message.TrackFile.Artist.Value));
        }
        public void Handle(TrackFileDeletedEvent message)
        {
            if (message.Reason == DeleteMediaFileReason.Upgrade)
            {
                return;
            }

            if (_configService.DeleteEmptyFolders)
            {
                var artist      = message.TrackFile.Artist.Value;
                var albumFolder = message.TrackFile.Path.GetParentPath();

                if (_diskProvider.GetFiles(artist.Path, SearchOption.AllDirectories).Empty())
                {
                    _diskProvider.DeleteFolder(artist.Path, true);
                }
                else if (_diskProvider.GetFiles(albumFolder, SearchOption.AllDirectories).Empty())
                {
                    _diskProvider.RemoveEmptySubfolders(albumFolder);
                }
            }
        }
예제 #6
0
 public void Handle(TrackFileDeletedEvent message)
 {
     _cache.Remove("AllArtists");
     _cache.Remove(message.TrackFile.Artist.Value.Id.ToString());
 }
예제 #7
0
 public void Handle(TrackFileDeletedEvent message)
 {
     _logger.Debug($"Detaching tracks from file {message.TrackFile}");
     _trackRepository.DetachTrackFile(message.TrackFile.Id);
 }
예제 #8
0
 public void Handle(TrackFileDeletedEvent message)
 {
     BroadcastResourceChange(ModelAction.Deleted, MapToResource(message.TrackFile));
 }