sharkwouter / minigalaxy

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

Fix Remove forward slash from desktop filename (Shenzhen I/O) #599

Closed slowsage closed 2 months ago

slowsage commented 3 months ago

Description

Installing Shenzhen I/O throws the following error:

Traceback (most recent call last):
  File "/usr/lib/python3.12/site-packages/minigalaxy/installer.py", line 72, in install_game
    error_message = create_applications_file(game)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/minigalaxy/installer.py", line 271, in create_applications_file
    os.remove(path_to_shortcut)
FileNotFoundError: [Errno 2] No such file or directory: '/home/USERNAME/.local/share/applications/SHENZHEN I/O.desktop'

/ is not a valid character for a filename in linux. This PR removes all / from the filename part of the path.

Checklist

slowsage commented 2 months ago

Can also add a one line helper function _sanitize_filename that is reused if thats cleaner. Not sure what you prefer.

sharkwouter commented 2 months ago

If you want to use a sanitize method, I would suggest you do the following:

slowsage commented 2 months ago

__strip_string excludes slashes already but unfortunately also spaces which messes up the desktop file names. I have changed the code to reuse get_stripped_name in installer.py and updated get_install_directory_name since its basically the same.

sharkwouter commented 2 months ago

Thanks for the fix! It's really appreciated!