Skip to content

Commit

Permalink
fix: Only perform a local song copy if paths aren't equal (#71)
Browse files Browse the repository at this point in the history
this fixes editing of local songs when the user doesn't edit the path

also, remove exists+remove check in favor of copy_options::overwrite_existing
  • Loading branch information
FlafyDev authored Nov 23, 2024
1 parent e9a7887 commit d3530f7
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions src/ui/nong_add_popup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -679,25 +679,25 @@ geode::Result<> NongAddPopup::addLocalSong(
}
destination /= unique;

if (std::filesystem::exists(destination, error_code)) {
std::filesystem::remove(destination, error_code);
}

bool result = std::filesystem::copy_file(songPath, destination, error_code);
if (error_code) {
return Err(fmt::format(
"Failed to save song. Please try again! Error category: {}, "
"message: {}",
error_code.category().name(),
error_code.category().message(error_code.value())));
}
if (!result) {
return Err(
"Failed to copy song to Jukebox's songs folder. Please try again.");
if (destination.compare(songPath) != 0) {
bool result = std::filesystem::copy_file(
songPath,
destination,
std::filesystem::copy_options::overwrite_existing,
error_code);
if (error_code) {
return Err(fmt::format(
"Failed to save song. Please try again! Error category: {}, "
"message: {}",
error_code.category().name(),
error_code.category().message(error_code.value())));
}
if (!result) {
return Err(
"Failed to copy song to Jukebox's songs folder. Please try again.");
}
}

std::string error = "";

LocalSong song = LocalSong{
SongMetadata{m_songID, id, songName, artistName, levelName, offset},
destination};
Expand Down

0 comments on commit d3530f7

Please sign in to comment.