Repository navigation
Read the Piebald usage archive from beside its database - #295
Conversation
Usage archives of deleted Piebald chats lived in Splitrail's state directory, apart from the database whose history they hold, so copying or backing up app.db (with -wal and -shm) left them behind. The archive is now one file beside the database, named after it (app.db.usage-archive), and parse_source merges the archive beside whatever database it parses. A fixture or another installation's copy therefore brings its own archive or none, which replaces the default-database path check. Only that exact path is read, so a .partial rebuild or another database in the folder is ignored. Merging, de-duplication by global_hash, and skipping an unreadable archive are unchanged.
|
Caution Review failedThe pull request is closed. Walkthrough
Merge Risk:
|
Why
#294 taught the Piebald analyzer to keep counting deleted chats from usage archives in
<state dir>/splitrail/piebald-archive/. In practice that put part of Piebald's history somewhere else. Copying, moving, or backing up Piebald's database (app.dbwith its-waland-shm) no longer carried everything Splitrail counts. Backup jobs that snapshotapp.dbskipped the archives without saying so. An archive is part of its database's history, so it should travel with the database.#294 hasn't shipped in a release yet (the latest is v3.12.0), so the location can change now without a migration path for released users.
What changed
app.dbbecomesapp.db.usage-archive(usage_archive_path). On Linux that's~/.local/share/piebald/app.db.usage-archive; macOS and Windows follow Piebald's own data directory.parse_sourcemerges the archive that sits beside whatever database it parses. This replaces the check that merged archives only into this machine's database (is_default_database). A test fixture or a copy of another installation brings its own archive or none, so it can't pick up this machine's, by construction rather than by comparing paths..partialfile beside it (an archive being rebuilt) and other databases in the folder are ignored, so writers rebuild the archive and rename it into place.global_hash, the live copy wins, and an unreadable archive is skipped with a warning.Unchanged: with no archive beside the database,
parse_sourcereturns exactly what it returned before. The watcher still treats onlyapp.dbitself as data. The archive is rewritten right before a deletion, and the deletion changesapp.db, so a refresh follows anyway (now noted in a comment).Validation
cargo fmt --checkcargo clippy --locked --all-targets -- -D warningscargo test --locked: 537 passed. The archive tests now put the archive beside the live fixture and parse it throughPiebaldAnalyzer::parse_source, so the path rule is exercised together with the merge. They cover:.partialfile and other databases ignoredapp.db.usage-archive(42 chats, 12,865 messages). I comparedsplitrail statsfrom the Keep counting usage of deleted Piebald chats from archives #294 build, reading the old folder, with this build, reading the file besideapp.db:Summary by CodeRabbit