fix(setup): repair the projects directory instead of creating it once - #109
Merged
Merged
Conversation
Deleting the default projects folder left the app permanently broken. The editor opened on a folder that was not there -- empty explorer, files that could not be saved, terminals starting in a missing directory -- and stayed that way through every relaunch and force-stop. The only ways back were clearing app data or installing a new version. It was created in createDirectories(), whose only caller returns early unless isFirstRun(), and that gates on versionName. So the directory was created once per app version and never looked at again. That matters for this directory and no other. Alone among the ones created there, it lives in app-external storage -- /storage/emulated/0/Android/data/<pkg>/files/projects -- which shows up in every file manager and is exactly the kind of path a cleaner app removes. The rest are under filesDir, where nothing outside the app can reach them. So this is not a partial fix: it is the only one that can disappear. The repair is idempotent and runs in two places, because either alone leaves a hole. SplashActivity's always-run block covers the launch path, beside the other repairs that exist for this same class of drift. But that activity can be skipped -- MainActivity can be started directly -- and the folder can be deleted while the app is running, so the consumer ensures it too, immediately before handing the path to the workbench. The URL-derived branch beside it already refused a path that was not a directory; the default now gets the same care. It asks isDirectory rather than exists. Neither can turn a file into a directory, so the difference is not the outcome -- it is whether anyone is told. exists() answers yes to a plain file sitting at that path and returns in silence, handing the workbench something it cannot open with nothing in the log. Three tests, mutation-checked in both directions: making the repair a no-op fails two of them, and reverting isDirectory to exists() fails the one that asserts the warning. The third test was a tautology on its first draft -- it asserted a state that holds either way -- and was rewritten to assert the signal, which is the only thing that actually differs. Fixes #81
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.
Summary
Deleting the default projects folder left the app permanently broken. The editor opened on a folder that was not there — empty explorer, files that could not be saved, terminals starting in a missing directory — and stayed that way through every relaunch and force-stop. The only ways back were clearing app data or installing a new version.
It was created in
createDirectories(), whose only caller returns early unlessisFirstRun(), and that gates onversionName. So the directory was created once per app version and never looked at again.Why only this directory
Alone among the ones created there, it lives in app-external storage —
/storage/emulated/0/Android/data/<pkg>/files/projects— which shows up in every file manager and is exactly the kind of path a cleaner app removes. The rest are underfilesDir, where nothing outside the app can reach them.So this is not a partial fix. It is the only one that can disappear.
Two call sites, because either alone leaves a hole
SplashActivity's always-run block covers the launch path, beside the other repairs that exist for this same class of drift.MainActivity.loadVSCodeensures it immediately before handing the path to the workbench — that activity can be started directly, and the folder can be deleted while the app is running. The URL-derived branch beside it already refused a path that was not a directory; the default now gets the same care.isDirectory, notexistsNeither can turn a file into a directory, so the difference is not the outcome — it is whether anyone is told.
exists()answers yes to a plain file sitting at that path and returns in silence, handing the workbench something it cannot open with nothing in the log.Tests, mutation-checked
isDirectory→exists()The third test was a tautology on its first draft — it asserted a state that holds either way — and was rewritten to assert the signal, which is the only thing that actually differs. Worth saying because a tautological test passes mutation testing by never having discriminated in the first place.
Fixes #81