Fleeym / jukebox

A NONG manager for Geometry Dash, written using Geode
18 stars 8 forks source link

Editing user added local songs causes the local song's file to be deleted #71

Closed FlafyDev closed 1 week ago

FlafyDev commented 1 week ago

in NongAddPopup::addLocalSong the code attempts to copy songPath into destination, so it fails when they are pointing to the same file. They are pointing to the same file when editing a local song.

The code fails because:

  1. It attempts to delete destination and copy songPath into it. But when they are the same file then songPath is also deleted.
  2. The copy function doesn't allow both inputs to point to the same file

The fix is checking with std::filesystem::path::compare if they are the same path. If it is the same path, then skip copying.

Also, I replaced the "exists then remove" with the copy option: std::filesystem::copy_options::overwrite_existing.

And removed the std::string error = ""; line. I think it's useless

Fleeym commented 1 week ago

I think the logic here was meant to handle the case where you want to change the song file too. Not sure I ever tested it though.

Fleeym commented 1 week ago

oh wait copy_file can overwrite the destination, never knew that