protected override bool DeleteTrack(DatabaseTrackInfo track) { if (ms_device != null && !ms_device.DeleteTrackHook(track)) { return(false); } DeleteTrackFile(track); return(true); }
protected override bool DeleteTrack(DatabaseTrackInfo track) { try { if (ms_device != null && !ms_device.DeleteTrackHook(track)) { return(false); } string track_file = System.IO.Path.GetFileName(track.Uri.LocalPath); string track_dir = System.IO.Path.GetDirectoryName(track.Uri.LocalPath); int files = 0; // Count how many files remain in the track's directory, // excluding self or cover art foreach (string file in System.IO.Directory.GetFiles(track_dir)) { string relative = System.IO.Path.GetFileName(file); if (relative != track_file && relative != CoverArtFileName) { files++; } } // If we are the last track, go ahead and delete the artwork // to ensure that the directory tree can get trimmed away too if (files == 0 && CoverArtFileName != null) { System.IO.File.Delete(Paths.Combine(track_dir, CoverArtFileName)); } Banshee.IO.Utilities.DeleteFileTrimmingParentDirectories(track.Uri); } catch (System.IO.FileNotFoundException) { } catch (System.IO.DirectoryNotFoundException) { } return(true); }