Fixed bug that caused a failure in retrieving records. Empty directories are deleted when deleting a song. If the song contains the stock cover art, the stock cover art will not be deleted

This commit is contained in:
amazing-username
2019-08-27 20:13:18 +00:00
parent ed6f98eb5a
commit d0d1008044
2 changed files with 12 additions and 4 deletions
+10 -4
View File
@@ -67,13 +67,19 @@ void song_manager::deleteSong(Song& song)
cov = covRepo.retrieveRecord(cov, coverFilter::id);
covRepo.deleteRecord(cov);
auto paths = directory_manager::pathConfigContent(exe_path);
const auto coverArtPath = paths["cover_root_path"].get<std::string>();
std::string stockCoverArtPath = coverArtPath;
stockCoverArtPath.append("CoverArt.png");
// TODO: only delete coverArt that is not the stock cover
// path
fs::remove(cov.imagePath);
if (stockCoverArtPath.compare(cov.imagePath) != 0) {
fs::remove(cov.imagePath);
std::cout << "deleting cover art" << std::endl;
}
fs::remove(song.songPath);
// TODO: delete empty directories
directory_manager::delete_directories(song, paths["root_music_path"].get<std::string>());
directory_manager::delete_directories(song, coverArtPath);
}
void song_manager::printSong(const Song& song)