The module docs and the persistence page named "no copy left" where a copy kept
before stays, said "never left behind under other names" without the `-2`
case, and the page said the log is appended before the command returns while
the log's thread writes and fsyncs it. They now say what the code does, and
that the damaged log's own name (`catalog.log.damaged-<seq>`) is written as it
always was.
New tests: a set whose snapshot is this very one but whose log holds other
bytes moves both files to `-2` (it fails without clearing the plan between
sets), and a hundred sets in the way refuse the upgrade without writing or
removing anything. The directory test puts the directory at the second file's
staging name, so the first copy is written and removed again.
The kept names (`catalog.snap.v<format>-<seq>`, `catalog.log.v<format>-<seq>`)
can be reached twice by a library restored from an older backup. `keep_replaced`
now reads the name first: a free name is written, the same bytes are the copy
already, other bytes make both names of the set end `-2` (then `-3`, up to 100
sets, then the upgrade is refused). Only what the call wrote is removed when
the upgrade does not happen, including a name whose write reported an error
(a rename that landed all the same).
`LoadReport::kept_files` says the store keeps what an upgrade replaces; the
notice for a damaged log needs it, so the browser's store, which keeps no
snapshot to go with the log, no longer says the library "as it was" is kept.
The persistence doc says the log is fsynced right after the command returns
natively, and the kept-file naming. A test locked `files` twice in one
assertion.
The entry said a library "saved by an earlier version" is upgraded, but an earlier
version can write the same catalog format, and opening such a library upgrades
nothing and keeps nothing. It now says a library saved in an older catalog format,
and the versions that can't open it afterward are the ones that don't know the
new format. The first paragraph of docs/catalog-persistence.md had the same
condition and now says it the same way.
The entry also said the library as it was is kept, but the browser build keeps no
copy (FilesStore::keeps_replaced_formats is false there). It now says the desktop
app keeps it and the browser build doesn't, as docs/catalog-persistence.md does.
The reworded sentence says "afterward", the American spelling.
Co-Authored-By: Claude <[email protected]>
A library left in its old format whose snapshot is in this build's format already (a write that landed and reported a failure) no longer fails every snapshot until it is reopened: it is the upgrade done, with nothing to keep. Tests now cover the files kept at open's length and seq when changes were made before the first attempt, the snapshot that landed after its files were kept, no second copy on a retry, the background worker's result and telling once. The docs say what the kept files hold when a session already added changes in the old format, what going back loses, and that a snapshot at close or a library switch has no one to tell.
A library left in an older format at open keeps its files when a later snapshot upgrades it. Those files are the library as it was at open (the snapshot, and the log up to its length then), under the names the open would have given them, so what is appended meanwhile in this build's ops is never in them. The snapshot hands the names on (Journal::take_kept) and the engine tells the person once, as the open does. Appends are not refused meanwhile (a library whose files can't be copied would save nothing): the module doc and the persistence doc say so.
Opening a library in an older format rewrites it in this build's, and older
builds then refuse it: a one-way step. Journal::open now first keeps the
files the library was, byte for byte, as catalog.snap.v<format>-<seq> and
catalog.log.v<format>-<seq>, and reports their names (LoadReport::kept).
Put back under their own names they are the library as the older build
left it (docs/catalog-persistence.md, Going back to an older version).
A library whose files can't be kept is not upgraded (it opens as it is; the
next open tries again), and an upgrade that fails leaves no copy; kept files
stay whenever the upgrade may have been written. A library whose log was
damaged is an upgrade like any other: its snapshot is kept beside the
damaged log, and it is refused if that log can't be replaced. The person is
told once where the library as it was is kept. A library left in its old format
at open is upgraded by a later snapshot (compaction, or closing), which keeps its
files first and is not written when it can't. The browser build keeps none
(Store::keeps_replaced_formats).
Co-Authored-By: Claude Opus 5.5 <[email protected]>