diff --git a/src/core/archive.py b/src/core/archive.py index 76e54573..db33d644 100644 --- a/src/core/archive.py +++ b/src/core/archive.py @@ -9,10 +9,15 @@ # Cleanup the cache dir before saving def cleanup_cache_dir(): print("Cleaning up the cache directory") - try: - shutil.rmtree(TEMP_CACHE) - except FileNotFoundError: - pass + # The workspace path can be left behind as a file or a symlink instead of a + # directory, and shutil.rmtree is not able to remove either of them + if os.path.islink(TEMP_CACHE) or os.path.isfile(TEMP_CACHE): + os.remove(TEMP_CACHE) + else: + try: + shutil.rmtree(TEMP_CACHE) + except FileNotFoundError: + pass os.makedirs(TEMP_CACHE, exist_ok=True) os.chdir(TEMP_CACHE) diff --git a/src/core/de_config.py b/src/core/de_config.py index 7154497a..dfbc13f3 100644 --- a/src/core/de_config.py +++ b/src/core/de_config.py @@ -91,6 +91,8 @@ def create_flatpak_list(): print("[OK] Saving Flatpak app list") def create_flatpak_autostart(): + # Without this, cp creates the workspace path as a file when it is missing + os.makedirs(f"{CACHE}/workspace", exist_ok=True) os.system(f"cp /app/share/savedesktop/savedesktop/core/flatpaks_installer.py {CACHE}/workspace") # Create a JSON file with the user's preferences for Flatpak apps