mirror of
https://github.com/DeeJanuz/frametop.git
synced 2026-10-29 04:01:26 +01:00
shutil.copy2 wrote <file>.ft-bak in place, so a copy cut off partway (a
full disk, a crash, the battery running out) left a short file. Since
b61b4d6 the backup is written only once, so that short file stayed for
good: os.path.exists finds it, the next repair skips the backup and goes
ahead. Before, the next repair at least wrote it again. With a 1 KiB limit
on file size, the first run left 1024 of the config's 2536 bytes, and the
second kept them and repaired.
The copy now goes to <file>.ft-bak.tmp, is fsynced, and only then takes its
name with os.replace; a failed copy removes the temporary file. If the
backup can't be written, the panels stay as they are, the reason goes to
the log, and the script exits 1 (the session goes on: it runs fix-panels
with || true). The next start tries again. That was already the outcome
of a failed copy, but through a traceback.
The new test runs fix-panels under that 1 KiB limit and checks that only
the config is left in its directory, unchanged, and that the next run
without the limit backs it up and repairs it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>