New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Check the input and destination paths before converting a game file onto itself #11576
Check the input and destination paths before converting a game file onto itself #11576
Conversation
Good idea, but now that std::filesystem works you might actually want to do this with something like
(after checking if dst_path exists) That also catches stuff like symlinks where the path is different but the underlying file is the same. |
Thanks for the advice! I'm gonna do it your way, I just want to add a counter of successfully converted files to avoid having a "Successfully converted 1 image(s)." right after the error message, but I don't know if I should do it in another PR or not |
…nto itself Before these changes you could tell Dolphin to convert a game file into the same format it is already in, leading to the FileDialog using the input path as the default destination path An unsuspecting user could then click Save and Dolphin would try to convert the input file by writing the destination file on top of it... leading to an I/O error and the input file being entirely removed
1ef0a1e
to
b5b7234
Compare
b5b7234
to
e3d9172
Compare
Oh what, Qt doesn't allow unsigned values as input to %n? That's silly... I guess revert to int then, whatever. |
e3d9172
to
49e8974
Compare
Shoot, didn't catch it before pushing, it worked on macOS |
|
|
Before these changes you could tell Dolphin to convert a game file into the same format it is already in, leading to the FileDialog using the input path as the default destination path
An unsuspecting user could then click Save and Dolphin would try to convert the input file by writing the destination file on top of it... leading to an I/O error and the input file being entirely removed
Instead of denying the user the ability to select the format already used by the input file (which would be annoying if someone wants to convert from RVZ to RVZ but with other compression settings), we can check if the input and destination paths are equal and error out before having the input file accidentally removed