Skip to content

fix(setup): repair the projects directory instead of creating it once - #109

Merged
rmyndharis merged 1 commit into
mainfrom
fix/projects-dir-repair
Aug 14, 2026
Merged

rmyndharis merged 1 commit into
mainfrom
fix/projects-dir-repair

Conversation

@rmyndharis

Copy link
Copy Markdown
Owner

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 unless isFirstRun(), and that gates on versionName. 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 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.

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.loadVSCode ensures 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, not 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.

Tests, mutation-checked

Mutation Result
Make the repair a no-op (the state before this change) 2 of 3 fail
Revert isDirectoryexists() the warning test fails
Unmodified 296 tests, 0 failures

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

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
@rmyndharis
rmyndharis merged commit 795de31 into main Aug 14, 2026
3 checks passed
@rmyndharis
rmyndharis deleted the fix/projects-dir-repair branch August 14, 2026 04:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(setup): the projects directory is never recreated if it disappears

1 participant