quak backup --verify re-hashes stored originals and downloads again any that do not match #168

Open
opened 2026-10-06 01:17:27 +02:00 by clawbot · 0 comments
Collaborator

Part of #162 (one cron-safe command that mirrors the whole account). Dispatched after #167 lands, which changes the same file.

What

quak backup --verify <dir> re-hashes every stored original against the content hash Ente records, and downloads again any that is missing or does not match.

New downloads are already checked against the recorded hash before they are renamed into place (#68); this unit checks what is already on disk.

Definition of done

  • quak backup --verify <dir> and lib.backup({ verify: true }): for each file in scope whose original is stored at its save path and whose metadata records a hash, hash the stored bytes the way the download check does (streamed; a live photo is <image hash>:<video hash>) and compare.
  • A mismatch is logged as one line naming the file, the stored original is removed (both files of a live photo) and downloaded again in the same run, like any missing one; a failed download goes to failures.json as usual.
  • A file with no recorded hash is counted as unchecked and left alone.
  • The result and the summary (and --json) gain the counts: verified, mismatched, unchecked.
  • Without --verify nothing is hashed and the run is unchanged.
  • The exit code says whether the mirror is complete: a mismatch that was downloaded again does not by itself make it non-zero.
  • README: --verify in "CLI surface" and "Backup layout".
  • Tests with stand-ins, never the real service: a good original is left untouched; a corrupted one is replaced; a live photo with one bad part is replaced; no recorded hash counts as unchecked; a failed re-download lands in failures.json.
  • TODO.md: an entry at the top of Completed Steps.

Notes

Reuse the hashing in src/crypto/hash.ts; read the file in chunks, never whole.

Touches src/backup.ts, src/library/index.ts, src/cli-commands.ts, bin/quak.ts, tests, README.md, TODO.md.

Model: opus-5-5

Part of https://git.eeqj.de/sneak/quak/issues/162 (one cron-safe command that mirrors the whole account). Dispatched after https://git.eeqj.de/sneak/quak/issues/167 lands, which changes the same file. ## What `quak backup --verify <dir>` re-hashes every stored original against the content hash Ente records, and downloads again any that is missing or does not match. New downloads are already checked against the recorded hash before they are renamed into place (https://git.eeqj.de/sneak/quak/issues/68); this unit checks what is already on disk. ## Definition of done - `quak backup --verify <dir>` and `lib.backup({ verify: true })`: for each file in scope whose original is stored at its save path and whose metadata records a hash, hash the stored bytes the way the download check does (streamed; a live photo is `<image hash>:<video hash>`) and compare. - A mismatch is logged as one line naming the file, the stored original is removed (both files of a live photo) and downloaded again in the same run, like any missing one; a failed download goes to `failures.json` as usual. - A file with no recorded hash is counted as unchecked and left alone. - The result and the summary (and `--json`) gain the counts: verified, mismatched, unchecked. - Without `--verify` nothing is hashed and the run is unchanged. - The exit code says whether the mirror is complete: a mismatch that was downloaded again does not by itself make it non-zero. - README: `--verify` in "CLI surface" and "Backup layout". - Tests with stand-ins, never the real service: a good original is left untouched; a corrupted one is replaced; a live photo with one bad part is replaced; no recorded hash counts as unchecked; a failed re-download lands in `failures.json`. - `TODO.md`: an entry at the top of Completed Steps. ## Notes Reuse the hashing in `src/crypto/hash.ts`; read the file in chunks, never whole. Touches `src/backup.ts`, `src/library/index.ts`, `src/cli-commands.ts`, `bin/quak.ts`, tests, `README.md`, `TODO.md`. Model: opus-5-5
clawbot self-assigned this 2026-10-06 01:17:27 +02:00
Sign in to join this conversation.