edge-host: fix settings-backup terminator check (trailing newline) #121

Merged
k.renner merged 1 commits from fix/edge-zwave-settings-backup-newline into master 2026-07-07 09:52:54 +00:00
Owner

Follow-up to #120. The settings.json backup guard checked tail -c1 == "}", but the file ends with }\n — so the last byte is a newline and the guard always skipped ("not }-terminated"), producing no backup. Verified live: the service logged the skip and no .bak was created.

Fix: strip trailing whitespace before the terminator check (tail -c 64 | tr -d '[:space:]' | tail -c1), so a valid newline-terminated file is backed up while a genuinely truncated/mid-write file is still rejected. Logic tested.

Docs/script only, no runtime/service change beyond the script contents. Applying just updates the script (no container bounce); I'll run the backup service once after to seed the first .bak.

Follow-up to #120. The settings.json backup guard checked `tail -c1 == "}"`, but the file ends with `}\n` — so the last byte is a newline and the guard always skipped ("not }-terminated"), producing **no backup**. Verified live: the service logged the skip and no `.bak` was created. Fix: strip trailing whitespace before the terminator check (`tail -c 64 | tr -d '[:space:]' | tail -c1`), so a valid newline-terminated file is backed up while a genuinely truncated/mid-write file is still rejected. Logic tested. Docs/script only, no runtime/service change beyond the script contents. Applying just updates the script (no container bounce); I'll run the backup service once after to seed the first `.bak`.
k.renner added 1 commit 2026-07-07 09:39:33 +00:00
The zwave-js settings backup guard in #120 checked `tail -c1 == "}"`, but
settings.json ends with "}\n" — so the last byte is a newline and the guard
always skipped ("not }-terminated"), producing no backup. Strip trailing
whitespace before the check so a valid, newline-terminated file is backed up
while a genuinely truncated one is still rejected.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
k.renner merged commit c4ae949bc0 into master 2026-07-07 09:52:54 +00:00
Sign in to join this conversation.