A file the host wrote over is given back when undeclared (hq ADR 0102, 0118) #92

Merged
mesh-admin merged 1 commits from fix/a-file-written-over-is-given-back into main 2026-10-04 10:54:50 +00:00
Contributor

Undeclaring a whole file used to delete it, even when the host had kept the original it wrote over. On a machine unassigning pacman, that would leave no /etc/pacman.conf.

removeWhole now handles each case:

  • the kept original is put back with its mode and owner, and read back;
  • a file the mesh created is removed;
  • a file changed or deleted since is left as it is, and the outcome says so;
  • a kept copy that is missing is said.

None of these is fatal.

Also fixed:

  • the original's mode and owner are now recorded when it is kept;
  • Kept is carried forward only when the path is the same;
  • a moved path keeps its own original before writing over it;
  • the plan shows "restore".

Seven new tests. go build, vet, test and gofmt are clean.

Undeclaring a whole file used to delete it, even when the host had kept the original it wrote over. On a machine unassigning `pacman`, that would leave no `/etc/pacman.conf`. `removeWhole` now handles each case: - the kept original is put back with its mode and owner, and read back; - a file the mesh created is removed; - a file changed or deleted since is left as it is, and the outcome says so; - a kept copy that is missing is said. None of these is fatal. Also fixed: - the original's mode and owner are now recorded when it is kept; - `Kept` is carried forward only when the path is the same; - a moved path keeps its own original before writing over it; - the plan shows "restore". Seven new tests. go build, vet, test and gofmt are clean.
mesh-admin added 1 commit 2026-10-04 10:54:42 +00:00
The host keeps the original of a file before writing over it (ADR 0102), but
removing the file's record deleted the file and never put the original back,
although ADR 0118 and the comment on meshMadeUnits say it does. A module writing
/etc/pacman.conf, logrotate.conf, locale.conf or vconsole.conf whole would, once
unassigned, leave the machine without the file.

removeWhole now decides, in order: no kept original (the mesh made it) is
removed as before; a file gone since is not brought back; a file changed since
the mesh last wrote it is left as it stands, as a block or JSON write-into stays
the machine's; an unreadable kept copy leaves the mesh's file in place. Otherwise
the original goes back atomically with the mode and owner it was found with,
now recorded beside Kept, and the outcome is "restored". None of it is fatal.
The plan says "restore" for such a file.

A kept original is carried only for the path it was kept from, and a file whose
path moved keeps the original at its new path first, so a moved file is never
given another path's original.
mesh-admin merged commit 89fce1dae3 into main 2026-10-04 10:54:50 +00:00
mesh-admin deleted branch fix/a-file-written-over-is-given-back 2026-10-04 10:54:51 +00:00
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: novox/mesh-host#92