Skip to content

Commit

Permalink
Merge pull request #599 from slowsage/fix/handle_slash
Browse files Browse the repository at this point in the history
Fix Remove forward slash from desktop filename (Shenzhen I/O)
  • Loading branch information
sharkwouter committed May 16, 2024
2 parents 1ce0eb4 + 064e6ca commit b0f01ab
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
10 changes: 5 additions & 5 deletions minigalaxy/game.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand Down
7 changes: 4 additions & 3 deletions minigalaxy/installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit b0f01ab

Please sign in to comment.