Repository navigation
Keep unreadable state files instead of overwriting them with defaults #986
Replies: 1 comment
|
I'd rather not take this one. This is a source-only proposal, with no reported reproduction or actual loss, and no plausible released-build or normal-use scenario behind it. the known compatibility failure in #360 was fixed at the field level: every optional in if you hit a real loss, or find a field that a released build or normal use can still make undecodable as a whole file, pls open an issue with the file and the build version. Then we can look at the specific failure. |
Uh oh!
There was an error while loading. Please reload this page.
I'd like to propose a small fix: keep a copy of a state file that can't be read, instead of overwriting it with defaults.
At current master
49ce3992, the state loaders treat a file that can't be read or decoded as if it were missing:PersistenceStore.load()returns an emptySnapshoton any read, decode or version failure.SettingsStore.load()returns the seeded defaults whensettings.jsondoes not decode.RecentClosedStore.load()returns an empty list forrecent-closed.json, andloadIndex()treats an undecodablewindows.jsonas absent.Nothing preserves the bad file before the next write.
AppStore.save()runs after every structural mutation and on terminate. So a truncated or hand-edited window file, or one written by a newer build, is replaced by the default on the next save. Asettings.jsonwith one typo is reset the same way. The user loses the file's contents without any message.There is a second effect on the launch inventory.
loadSnapshotForStorealready marks the inventory incomplete whenloadChecked()fails, so the first launch does not reap. But that window then saves the empty default. On the next launch the file is valid and empty, the inventory counts as complete, and the daemons the lost tree had claimed look unclaimed.I traced this by reading the source. I have not reproduced it in the macOS app.
Proposed scope, kept small:
<name>.unreadable-<UTC stamp>in the same directory and logs one line naming the copy. The line says so when the file's version is newer than the build's.We carry a version of this in a Linux downstream fork. I would write a separate change against master, without Linux-specific code, and run
make build,make test,make test-appandmake lintbefore sending it.Would a PR like this be welcome? Or do you prefer the current reset-to-defaults behaviour for some of these files?
This investigation was AI-assisted. I'm following the discussion-first process; no upstream code has been written.
This proposal was prepared with AI assistance (Claude); I reviewed it. If you agree, I will open a PR with tests.
All reactions