Skip to content

Commit

Permalink
Fix uninstall paths on windows (#44)
Browse files Browse the repository at this point in the history
* fix: bad path separator substitution during uninstall

* feat: remove empty directories on uninstall
  • Loading branch information
m3e-g authored Jan 25, 2024
1 parent 8f7ab26 commit 731d653
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion nile/utils/uninstall.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,19 @@ def uninstall(self):

files = self.manifest.packages[0].files
for f in files:
os.remove(os.path.join(installed_info["path"], f.path.replace("\\", "/")))
# Manifest can contain both kind of slash as a separator on the same entry
os.remove(os.path.join(installed_info["path"], f.path.replace("\\", os.sep).replace("/", os.sep)))

# Remove empty directories under the installation directory
for dirpath, dirnames, filenames in os.walk(installed_info["path"], topdown=False):
for dirname in dirnames:
full_path = os.path.join(dirpath, dirname)
if not os.listdir(full_path):
os.rmdir(full_path)

# Remove installation directory if it's empty
if not os.listdir(installed_info["path"]):
os.rmdir(installed_info["path"])

self.config.write("installed", installed_games)
self.config.remove(f"manifests/{game_id}", cfg_type=ConfigType.RAW)
Expand Down

0 comments on commit 731d653

Please sign in to comment.