Read the snapshot name using the stored hostname #261

Merged
clawbot merged 1 commits from issue-230-hostname-underscore-purge into next 2026-10-07 12:12:09 +02:00
Collaborator

Fixes #230.

Per-name retention (snapshot purge --snapshot, --keep-latest, and snapshot create --prune) read a snapshot's name from its ID as everything between the first and the last _. With a hostname such as my_host, the name home came out as host_home, so a purge by name selected nothing: snapshot purge --keep-latest --snapshot home printed "No snapshots to delete", and snapshot create --prune purged nothing without a message.

Purge now reads the name using the hostname the snapshots table stores with each snapshot: it removes that hostname and its _ from the front of the ID, and the last _ and the timestamp from the end. The ID holds the hostname cut at its first . while the table holds the full one; that cut is now snapshot.ShortHostname, used both where the ID is written and where it is read.

  • Judgement call: of the two fixes the issue offers, this takes the stored-hostname one. Rejecting _ in hostname when the config loads would also refuse every command, restore included, on a host whose system hostname contains one.
  • An ID that does not start with its stored hostname yields an empty name. Creating a snapshot never writes such a row, but the fixture in purge_local_remote_consistency_test.go did (test-host against testhost_ IDs); it now stores the matching hostname.
  • setupPurgeTest now takes the hostname as a parameter. The new tests use the names docs and mail because a third "home" literal trips goconst.

Model: opus-5-5

Fixes https://git.eeqj.de/sneak/vaultik/issues/230. Per-name retention (`snapshot purge --snapshot`, `--keep-latest`, and `snapshot create --prune`) read a snapshot's name from its ID as everything between the first and the last `_`. With a hostname such as `my_host`, the name `home` came out as `host_home`, so a purge by name selected nothing: `snapshot purge --keep-latest --snapshot home` printed "No snapshots to delete", and `snapshot create --prune` purged nothing without a message. Purge now reads the name using the hostname the `snapshots` table stores with each snapshot: it removes that hostname and its `_` from the front of the ID, and the last `_` and the timestamp from the end. The ID holds the hostname cut at its first `.` while the table holds the full one; that cut is now `snapshot.ShortHostname`, used both where the ID is written and where it is read. - Judgement call: of the two fixes the issue offers, this takes the stored-hostname one. Rejecting `_` in `hostname` when the config loads would also refuse every command, restore included, on a host whose system hostname contains one. - An ID that does not start with its stored hostname yields an empty name. Creating a snapshot never writes such a row, but the fixture in `purge_local_remote_consistency_test.go` did (`test-host` against `testhost_` IDs); it now stores the matching hostname. - `setupPurgeTest` now takes the hostname as a parameter. The new tests use the names `docs` and `mail` because a third `"home"` literal trips goconst. Model: opus-5-5
clawbot self-assigned this 2026-10-07 10:11:17 +02:00
clawbot added the needs-review label 2026-10-07 10:11:21 +02:00
Author
Collaborator
  1. TODO.md:30-31: the new entry says snapshot purge --snapshot home "purged nothing, without a message". That command as written exits with "must specify either --keep-latest or --older-than", and snapshot purge --keep-latest --snapshot home printed "No snapshots to delete"; only snapshot create --prune gave no message. Acceptable: name snapshot purge --keep-latest --snapshot home, and say only snapshot create --prune was silent. The commit message body names the same command and needs the same fix.

Model: opus-5-5

1. `TODO.md:30-31`: the new entry says `snapshot purge --snapshot home` "purged nothing, without a message". That command as written exits with "must specify either --keep-latest or --older-than", and `snapshot purge --keep-latest --snapshot home` printed "No snapshots to delete"; only `snapshot create --prune` gave no message. Acceptable: name `snapshot purge --keep-latest --snapshot home`, and say only `snapshot create --prune` was silent. The commit message body names the same command and needs the same fix. Model: opus-5-5
clawbot added needs-rework and removed needs-review labels 2026-10-07 10:30:17 +02:00
clawbot added 1 commit 2026-10-07 11:33:05 +02:00
A snapshot ID is hostname_name_timestamp, and purge took the name to be
everything between the first and the last underscore. With a hostname
such as my_host the name home came out as host_home, so
`snapshot purge --keep-latest --snapshot home` found nothing to delete
and `snapshot create --prune` purged nothing without a message. The name
is now read by removing the hostname stored with the snapshot, in the
short form the ID uses, so both may contain underscores. This was chosen
over rejecting underscores in `hostname` when the config loads, which
would also stop restores on such a host.

The purge consistency test stored a hostname that did not match its
snapshot IDs; it now matches, as it always does in production.

Model: opus-5-5
clawbot force-pushed issue-230-hostname-underscore-purge from fd3f317e45 to 83a9800b20 2026-10-07 11:33:05 +02:00 Compare
Author
Collaborator

Rework delta:

  1. TODO.md and the commit message now name snapshot purge --keep-latest --snapshot home and say it printed "No snapshots to delete"; only snapshot create --prune is described as silent. The PR body had the same wrong "said nothing" and is corrected the same way.

Also rebased onto next after #259; both TODO.md entries are kept, this one first.

Model: opus-5-5

Rework delta: 1. `TODO.md` and the commit message now name `snapshot purge --keep-latest --snapshot home` and say it printed "No snapshots to delete"; only `snapshot create --prune` is described as silent. The PR body had the same wrong "said nothing" and is corrected the same way. Also rebased onto `next` after https://git.eeqj.de/sneak/vaultik/pulls/259; both `TODO.md` entries are kept, this one first. Model: opus-5-5
clawbot added needs-review and removed needs-rework labels 2026-10-07 11:33:16 +02:00
Author
Collaborator

Review passed.
Model: opus-5-5

Review passed. Model: opus-5-5
clawbot merged commit 3fc8a8f2f4 into next 2026-10-07 12:12:09 +02:00
clawbot deleted branch issue-230-hostname-underscore-purge 2026-10-07 12:12:09 +02:00
Sign in to join this conversation.