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:
@@ -174,6 +174,7 @@ std::vector<Song> songRepository::parseRecords(MYSQL_RES* results)
|
|||||||
break;
|
break;
|
||||||
case 7:
|
case 7:
|
||||||
song.songPath = row[i];
|
song.songPath = row[i];
|
||||||
|
break;
|
||||||
case 8:
|
case 8:
|
||||||
song.coverArtId = std::stoi(row[i]);
|
song.coverArtId = std::stoi(row[i]);
|
||||||
break;
|
break;
|
||||||
@@ -221,6 +222,7 @@ Song songRepository::parseRecord(MYSQL_RES* results)
|
|||||||
break;
|
break;
|
||||||
case 8:
|
case 8:
|
||||||
song.coverArtId = std::stoi(row[i]);
|
song.coverArtId = std::stoi(row[i]);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
std::cout << "done parsing record" << std::endl;
|
std::cout << "done parsing record" << std::endl;
|
||||||
|
|||||||
@@ -67,13 +67,19 @@ void song_manager::deleteSong(Song& song)
|
|||||||
cov = covRepo.retrieveRecord(cov, coverFilter::id);
|
cov = covRepo.retrieveRecord(cov, coverFilter::id);
|
||||||
covRepo.deleteRecord(cov);
|
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
|
if (stockCoverArtPath.compare(cov.imagePath) != 0) {
|
||||||
// path
|
|
||||||
fs::remove(cov.imagePath);
|
fs::remove(cov.imagePath);
|
||||||
|
std::cout << "deleting cover art" << std::endl;
|
||||||
|
}
|
||||||
fs::remove(song.songPath);
|
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)
|
void song_manager::printSong(const Song& song)
|
||||||
|
|||||||
Reference in New Issue
Block a user