Fix saving when the cache workspace path is a file - #555
Open
shreyanshj10 wants to merge 1 commit into
Open
shreyanshj10 wants to merge 1 commit into
shreyanshj10 wants to merge 1 commit into
Conversation
shreyanshj10
marked this pull request as ready for review
October 1, 2026 09:12
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull request
Description
Saving fails permanently with
NotADirectoryError: [Errno 20] Not a directory: .../cache/tmp/workspacewhen the workspace path in the cache directory happens to be a file instead of a directory.cleanup_cache_dir()only catchesFileNotFoundError, soshutil.rmtree()raises and every save attempt ends in "An error occurred" until the user deletes that file by hand.Two changes:
cleanup_cache_dir()now removes the workspace path withos.remove()when it is a file or a symlink, and keeps usingshutil.rmtree()otherwise. The app recovers on its own instead of staying broken.create_flatpak_autostart()creates the workspace directory before thecp. This is where the stray file comes from:cp <file> {CACHE}/workspacecreatesworkspaceas a file when the directory is not there, and the nextcreate_flatpak_autostart()call would fail on theflatpak-prefs.jsonwrite anyway.Related Issue
Changes Made
Screenshots (if applicable)
Not applicable, no visual changes.
Testing
I exercised
cleanup_cache_dir()directly against three states of the workspace path - missing, an existing directory with content in it, and a plain file - and confirmed that it raises on the third one before the change and leaves an empty directory behind in all three after it.Checklist
Additional Notes
remove_cache()ingui/window.pyandcache_cleanup()ingui/flatpaks_installer_window.pycallshutil.rmtree()on the same path behind anos.path.exists()check, so they would hit the same error on a cache that is already in this state. I left them alone to keep this focused on the save path from the issue, but happy to include them if you would like.