Skip to content

fix(configurator): replace local files with repo config symlinks, back them up, keep linking on errors - #374

Open
gmmcosta15 wants to merge 3 commits into
devfrom
fix/symlink-config-skip-existing
Open

gmmcosta15 wants to merge 3 commits into
devfrom
fix/symlink-config-skip-existing

Conversation

@gmmcosta15

Copy link
Copy Markdown
Collaborator

Description

  • Feature
  • Bug Fix
  • Code Refactor
  • Documentation

On every start, ConfigManager.sync links each RF50-Klipper config file into the printer's config folder. If a regular file already sat where a link belongs (a hand-copied cfg, a leftover from an older deploy, a local edit), _symlink_config raised FileExistsError. That file stayed local, so repo fixes never reached it. Because a single try wrapped the whole loop, every repo file after it was skipped too, on every boot, with only one error line in the log. A new cfg added to the repo could silently never reach Klipper.

Changes

  • A local file in place of a repo link is moved to the backup folder (~/.rf50_backups/<path>.<timestamp>, same as the variables.cfg repair) and replaced with the link, so the repo config always wins.
  • Errors are handled per file: one failed link is logged and the rest are still linked. Folders in the way are never deleted.
  • A file reached through a folder link into the repo (or a config folder that is itself the repo) is the repo's own copy and is skipped, so repo files are never moved.
  • Existing links, files that exist only on the machine, and the copied files (printer.cfg, variables.cfg, BlocksScreen.cfg) are unchanged.

Motivation

The config folder is meant to mirror the repo on every start, so a local change cannot break a machine. One stray file defeated that and also blocked every later link, including new configs shipped with updates.

Tests

  • New unit tests in tests/util/test_configurator_unit.py:
    • a local file is replaced and backed up;
    • a failed link does not stop later ones;
    • repo files behind a folder link, or a config folder linked to the repo, are left untouched.
  • The replace and failed-link tests fail on the old code; the folder-link tests guard against moving repo files.
  • Ran the link step against a copy of a real printer config layout: the edited file was replaced and backed up, the new repo file was linked, and the repo was unchanged.

@gmmcosta15
gmmcosta15 requested a review from a team October 30, 2026 17:04
@gmmcosta15 gmmcosta15 added the bug Something is broken, or a fix for it label Oct 30, 2026
@gmmcosta15 gmmcosta15 self-assigned this Oct 30, 2026

This branch has not been deployed

No deployments
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