inspect: open the archive read-only #34

Merged
jcoffey-dev merged 1 commits from fix/inspect-read-only into main 2026-10-30 15:05:07 +00:00
Owner

Roadmap item 11, part one: inspect opens the archive read-only and never creates one.

Before this, inspect went through init::open. Inspecting a mistyped path created an empty archive there, and inspecting an older archive upgraded its layout. Both contradict the usage docs, which said it never writes.

Now it uses init::open_read_only:

  • If there's no archive at the path, or the file isn't an archive, that's an error and nothing is created.
  • An archive that lacks part of today's schema is refused, not changed.
  • An archive that another run holds is reported as in use.
  • A closed archive (no -wal) is opened immutable. Without that, SQLite leaves -shm and -wal files even after a read-only open.
  • When there is a -wal, from a run that's still going or was interrupted, it's opened read-only so those writes still show.

Tests in db::init:

  • reading leaves every file's hash unchanged and adds no side files, and writes are refused;
  • a missing file, a foreign SQLite file and a plain-text file are each refused;
  • an older layout is refused and left as it was;
  • an interrupted run's rows are shown from the -wal;
  • a held archive reports "in use";
  • the URI encoding.

I also checked the built binary by hand: an archive imported from a Maildir hashes the same after inspect, and a mistyped path exits with an error and creates nothing.

Checks: fmt, clippy -D warnings, cargo test --locked (1476 passed).

The Maildir keywords part of item 11 was already done: the reader existed, and #26 fixed it to match.

Roadmap item 11, part one: `inspect` opens the archive read-only and never creates one. Before this, `inspect` went through `init::open`. Inspecting a mistyped path created an empty archive there, and inspecting an older archive upgraded its layout. Both contradict the usage docs, which said it never writes. Now it uses `init::open_read_only`: - If there's no archive at the path, or the file isn't an archive, that's an error and nothing is created. - An archive that lacks part of today's schema is refused, not changed. - An archive that another run holds is reported as in use. - A closed archive (no `-wal`) is opened `immutable`. Without that, SQLite leaves `-shm` and `-wal` files even after a read-only open. - When there is a `-wal`, from a run that's still going or was interrupted, it's opened read-only so those writes still show. Tests in `db::init`: - reading leaves every file's hash unchanged and adds no side files, and writes are refused; - a missing file, a foreign SQLite file and a plain-text file are each refused; - an older layout is refused and left as it was; - an interrupted run's rows are shown from the `-wal`; - a held archive reports "in use"; - the URI encoding. I also checked the built binary by hand: an archive imported from a Maildir hashes the same after `inspect`, and a mistyped path exits with an error and creates nothing. Checks: fmt, clippy `-D warnings`, `cargo test --locked` (1476 passed). The Maildir keywords part of item 11 was already done: the reader existed, and #26 fixed it to match.
jcoffey-dev added 1 commit 2026-10-30 15:01:27 +00:00
inspect: open the archive read-only
ci / test (pull_request) Skipped
github/ci (branch) GitHub Actions
ci / github (pull_request) Successful in 3m31s
ci / announce (pull_request) Skipped
3ee9167afc
inspect went through init::open, which creates a missing archive and
brings an older layout up to date. It now uses init::open_read_only:
a missing path or a file that isn't an archive is an error, an archive
missing part of today's schema is refused rather than changed, and an
archive another run holds is reported as in use.

A closed archive has no -wal file and is opened immutable, so reading it
leaves nothing beside it; SQLite otherwise adds -shm and -wal files even
for a read-only connection. With a -wal there, it is opened read-only so
an interrupted run's writes are shown.
jcoffey-dev merged commit dadf8de975 into main 2026-10-30 15:05:07 +00:00
jcoffey-dev deleted branch fix/inspect-read-only 2026-10-30 15:05:07 +00:00
Sign in to join this conversation.