Skip to content

Fix: re-read the config file before every write - #497

Merged
SandObserver merged 1 commit into
mainfrom
fix/config-reread-before-write
Oct 18, 2026
Merged

SandObserver merged 1 commit into
mainfrom
fix/config-reread-before-write

Conversation

@SandObserver

Copy link
Copy Markdown
Owner

Summary

  • Split the file read, parse and shape check out of loadConfig into _readDisk.
  • Call _readDisk at the start of saveConfig instead of trusting the in-memory damage flag, so a file broken inside the 5 s cache window is backed up and refused.
  • Make loadConfigForUpdate bypass the cache, and use it for the stale-write check in POST /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

  • Keep a config file edited by hand while the container runs instead of overwriting it on the next save.

Checklist

  • Stays within the project constraints: one container, no runtime dependencies, no build step (see CONTRIBUTING.md).
  • Tests added or updated for new logic, and the full suite, lint, and typechecks pass.
  • Docs updated if behavior or configuration changed.

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.
@SandObserver SandObserver added the bug Something isn't working label Oct 18, 2026
@SandObserver
SandObserver merged commit 0fab63a into main Oct 18, 2026
6 checks passed
@SandObserver
SandObserver deleted the fix/config-reread-before-write branch October 18, 2026 22:19
stackyard-release Bot pushed a commit that referenced this pull request Oct 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant