Repository navigation
Fix: re-read the config file before every write - #497
Merged
Merged
Conversation
Writes loaded the config from the 5 second read cache. A file broken by hand inside that window was overwritten by the cached copy, with no corrupt-file backup, and a valid hand edit was lost. saveConfig now checks the file itself before writing, so a broken file is backed up and kept. loadConfigForUpdate and the config route's stale-write check read the file, not the cache.
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
loadConfiginto_readDisk._readDiskat the start ofsaveConfiginstead of trusting the in-memory damage flag, so a file broken inside the 5 s cache window is backed up and refused.loadConfigForUpdatebypass the cache, and use it for the stale-write check inPOST /api/config, so read-modify-write paths keep a hand edit.Testing
All green. Added 2 tests: a file broken after the last read survives the next save with a backup, and a hand edit survives a read-modify-write.
Changelog
Fixed
Checklist