Module backup

Source
Expand description

One file holding everything Aède knows, so that a disk failure costs a scan and not a year of listening.

Six independently versioned stores are nested whole: the mostly derived catalog (which also holds watched roots), costly byte-level conclusions, irreplaceable user statements, slowly re-fetchable external sources, and private account credentials, and parental policies/usage. Versions 1 and 2 carry no accounts; versions 1 through 3 carry no parental store. A version-1 envelope is still accepted: its embedded legacy conclusions are extracted into the fourth store before restoration.

§A document of documents, and why that matters

The six are nested as they are, each keeping its own format_version and read back by its own from_json. Nothing here re-encodes a catalog, so a field added to the catalog tomorrow is in the backup tomorrow, with no second writer to forget it — the fault that would otherwise be discovered the day somebody restored one.

The consequence worth stating: each store is refused on its own. A backup written by an Aède whose catalog format has since moved still restores the notes and the fetched facts, because the catalog’s version check has nothing to say about user.json. A single check at the top would have thrown away irreplaceable data to protect the rebuildable catalog.

§It stores, it never fetches or scans

Reading a backup produces documents; writing one consumes them. Nothing here touches the library, and — as everywhere in this program — nothing here touches an audio file.

Structs§

Backup
Everything Aède knows, at one moment.

Enums§

Part
One store inside a backup, and what this build can do with it.

Constants§

BACKUP_FORMAT_VERSION
The version of the wrapper, which is not the version of what it wraps.

Functions§

from_json
Reads back what to_json wrote.
read
Reads a backup from an ordinary local file, refusing blocking special files. A backup with credentials also requires a private, non-symlink source. The opened file’s identity and permissions are checked, and changes during reading are refused. Reading cannot grow past its inspected length.
to_json
The envelope, with the six documents nested unchanged.
write
Writes a backup through isolated temporary output and atomic replacement.