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); } }
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); }
public void Handle(TrackFileDeletedEvent message) { foreach (var track in message.TrackFile.Tracks.Value) { track.TrackFile = message.TrackFile; BroadcastResourceChange(ModelAction.Updated, MapToResource(track, true, true)); } }
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); } } }
public void Handle(TrackFileDeletedEvent message) { _cache.Remove("AllArtists"); _cache.Remove(message.TrackFile.Artist.Value.Id.ToString()); }
public void Handle(TrackFileDeletedEvent message) { _logger.Debug($"Detaching tracks from file {message.TrackFile}"); _trackRepository.DetachTrackFile(message.TrackFile.Id); }
public void Handle(TrackFileDeletedEvent message) { BroadcastResourceChange(ModelAction.Deleted, MapToResource(message.TrackFile)); }