diff --git a/nile/utils/uninstall.py b/nile/utils/uninstall.py index 1eee27d..0371b49 100644 --- a/nile/utils/uninstall.py +++ b/nile/utils/uninstall.py @@ -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)