sharkwouter / minigalaxy

A simple GOG client for Linux
https://sharkwouter.github.io/minigalaxy/
GNU General Public License v3.0
1.1k stars 71 forks source link

Create filesystem_utils.py module #218

Open makson96 opened 3 years ago

makson96 commented 3 years ago

At the moment uninstalling game looks like:

def uninstall_game(game):
    shutil.rmtree(game.install_dir, ignore_errors=True)

I am always scared when I see code like this. What if due to misconfiguration or bug, we end up with gamw.install_dir being some important user directory? Disaster.

I propose to create filesystem_utils.py module, which will abstract file operation (especially destructive ones: move, remove) and make sure that they executed only in ~/.cache/minigalaxy or ~/.config/minigalaxy or Config.get("install_dir"). Then we can make all modules to use filesystem_utils instead of directly calling files operation. With such a change it will be a lot safer to perform files operations. If you approve. I can proceed with the work. Best regards,

sharkwouter commented 3 years ago

I do like this idea. I had not really considered how scary that command can actually be. Good find, thanks!