Skip to content

fix(configurator): write printer.cfg atomically at boot - #361

Merged
gmmcosta15 merged 4 commits into
devfrom
fix/boot-config-atomic-write
Oct 21, 2026
Merged

gmmcosta15 merged 4 commits into
devfrom
fix/boot-config-atomic-write

Conversation

@gmmcosta15

Copy link
Copy Markdown
Collaborator

Description

  • Feature
  • Bug Fix
  • Code Refactor
  • Documentation

At boot, ConfigManager.merge_cfg overwrote printer.cfg in place. If power was lost during that write, printer.cfg was left truncated. The next boot then rebuilt it from the repo and lost the SAVE_CONFIG block (z offset, beacon calibration). merge_cfg now writes through the same atomic helper device_configurator.py already used, moved into helper_methods.py so both modules share it.

Changes

  • atomic_write_text moved from device_configurator.py to helper_methods.py
  • ConfigManager.merge_cfg writes through it (temp file + fsync + os.replace, mode and symlink kept)
  • Test: a failed write keeps the old printer.cfg and its SAVE_CONFIG block

Motivation

merge_cfg rewrote printer.cfg in place. A power cut during the first boot after an update truncated it, and the next boot rebuilt it from the repo, losing SAVE_CONFIG data (z offset, beacon calibration).

@gmmcosta15 gmmcosta15 added the bug Something is broken, or a fix for it label Oct 21, 2026
@gmmcosta15 gmmcosta15 self-assigned this Oct 21, 2026
@gmmcosta15
gmmcosta15 merged commit 924e892 into dev Oct 21, 2026
9 checks passed
@gmmcosta15
gmmcosta15 deleted the fix/boot-config-atomic-write branch October 21, 2026 16:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something is broken, or a fix for it

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant