From 064e6ca6ef4ce0ca99793d8153495fb5c35e807a Mon Sep 17 00:00:00 2001 From: slowsage <84777606+slowsage@users.noreply.github.com> Date: Mon, 29 Apr 2024 14:28:55 -0400 Subject: [PATCH] Fix Remove forward slash from desktop filename (Shenzhen I/O) --- CHANGELOG.md | 1 + minigalaxy/game.py | 10 +++++----- minigalaxy/installer.py | 7 ++++--- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ee5bb3c3..d9684211 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,5 @@ **1.3.0** +- Fix Remove forward slash from desktop filename for Shenzhen I/O (thanks to slowsage) - Fix race when preparing download location (thanks to viacheslavka) - Fix multithreaded downloads of Windows games (thanks to viacheslavka) - Fix DLC installation for Windows games (thanks to viacheslavka) diff --git a/minigalaxy/game.py b/minigalaxy/game.py index 7069b6d8..f04fb985 100644 --- a/minigalaxy/game.py +++ b/minigalaxy/game.py @@ -19,11 +19,11 @@ def __init__(self, name: str, url: str = "", md5sum=None, game_id: int = 0, inst self.category = category self.status_file_path = self.get_status_file_path() - def get_stripped_name(self): - return self.__strip_string(self.name) + def get_stripped_name(self, to_path=False): + return self.__strip_string(self.name, to_path) def get_install_directory_name(self): - return re.sub('[^A-Za-z0-9 ]+', '', self.name) + return self.__strip_string(self.name, to_path=True) def get_status_file_path(self): if self.install_dir: @@ -47,8 +47,8 @@ def save_minigalaxy_info_json(self, json_dict): json.dump(json_dict, status_file) @staticmethod - def __strip_string(string): - return re.sub('[^A-Za-z0-9]+', '', string) + def __strip_string(string, to_path=False): + return re.sub('[^A-Za-z0-9]+', '', string) if not to_path else re.sub('[^A-Za-z0-9 ]+', '', string) def is_installed(self, dlc_title="") -> bool: installed = False diff --git a/minigalaxy/installer.py b/minigalaxy/installer.py index c8ba953a..fa0a4d29 100644 --- a/minigalaxy/installer.py +++ b/minigalaxy/installer.py @@ -245,7 +245,7 @@ def get_exec_line(game): def create_applications_file(game): error_message = "" - path_to_shortcut = os.path.join(APPLICATIONS_DIR, "{}.desktop".format(game.name)) + path_to_shortcut = os.path.join(APPLICATIONS_DIR, "{}.desktop".format(game.get_stripped_name(to_path=True))) exe_cmd = get_exec_line(game) # Create desktop file definition desktop_context = { @@ -336,8 +336,9 @@ def uninstall_game(game): shutil.rmtree(game.install_dir, ignore_errors=True) if os.path.isfile(game.status_file_path): os.remove(game.status_file_path) - if os.path.isfile(os.path.join(APPLICATIONS_DIR, "{}.desktop".format(game.name))): - os.remove(os.path.join(APPLICATIONS_DIR, "{}.desktop".format(game.name))) + path_to_shortcut = os.path.join(APPLICATIONS_DIR, "{}.desktop".format(game.get_stripped_name(to_path=True))) + if os.path.isfile(path_to_shortcut): + os.remove(path_to_shortcut) def _exe_cmd(cmd):