Commit Graph
10 Commits
Author SHA1 Message Date
FredApps 8b05bc2b5e catalog: a snapshot that landed despite an error tells its kept files at once; persistence doc says which writes wait (CodeRabbit on #2867) 2026-11-26 21:48:28 +07:00
Nathaniel Ledford 6e91bf4a77 Catalog: the kept-file docs say a copy kept earlier stays, the damaged log keeps its own name, and the log is written by its thread; two tests for the sets that are in the way
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.
2026-11-07 18:24:26 -05:00
Nathaniel Ledford c54c05c103 Catalog: an upgrade never replaces or removes a kept file that was there; the notice for a damaged log needs a store that keeps files; the doc says when the log is fsynced
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.
2026-11-07 18:04:20 -05:00
Nathaniel LedfordandClaude c914ca0c8b Catalog: the What's New entry names the older catalog format and says the desktop app keeps the copy
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]>
2026-11-07 16:41:05 -05:00
Nathaniel Ledford b28e2ae7b8 Upgrade notice names a damaged log kept by the upgrade; the way back renames a kept catalog.log.damaged-<seq> like any kept log 2026-11-07 16:41:05 -05:00
Nathaniel Ledford c59f99986f Catalog: the damaged-log bullet and the module docs say what is left when the log can't be replaced, and what a later snapshot keeps 2026-11-07 16:41:05 -05:00
Nathaniel Ledford 1dfb033459 Catalog: the docs and comments say what a failed later snapshot leaves: the files kept at open stay, as they were then 2026-11-07 16:41:05 -05:00
Nathaniel Ledford 74121ac83d Catalog: a snapshot already in this format is the upgrade done, and the later upgrade's tests and docs are exact
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.
2026-11-07 16:41:05 -05:00
Nathaniel Ledford dfea36c857 Catalog: a later upgrade tells where it kept the files it replaced
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.
2026-11-07 16:41:05 -05:00
Nathaniel LedfordandClaude Opus 5.5 70a7c2bf8d Catalog: an upgrade keeps the files it replaces
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]>
2026-11-07 16:41:05 -05:00