From a1584bc8b37635cdf05ad7a3fe39ef9f7e83f620 Mon Sep 17 00:00:00 2001 From: sneak Date: Wed, 14 Oct 2026 00:40:15 +0000 Subject: [PATCH] Test: a backup limited to one album stores a file whose copy there does not decrypt A run of lib.backup() limited to "Trip" must store a file whose copy in Trip does not decrypt when its copy in an album the run skips does. Today the run neither stores it nor records it as failed. Model: opus-5-5 --- test/cli/backup-undecryptable.test.ts | 37 ++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/test/cli/backup-undecryptable.test.ts b/test/cli/backup-undecryptable.test.ts index 72adc11..9500dc0 100644 --- a/test/cli/backup-undecryptable.test.ts +++ b/test/cli/backup-undecryptable.test.ts @@ -37,8 +37,9 @@ import { type CliContext, } from "../../src/cli-commands.js"; import { loadSession } from "../../src/cli-session.js"; -import type { ClientSnapshot } from "../../src/client.js"; +import { Client, type ClientSnapshot } from "../../src/client.js"; import { encryptBlob, init, toBase64 } from "../../src/crypto/index.js"; +import { Library } from "../../src/library/index.js"; const USER_ID = 42; @@ -412,6 +413,40 @@ describe("quak backup with records it cannot decrypt", () => { expect(stored(30)).toBe(true); expect(failures()).toEqual({}); }); + + it("backs up that file in a run limited to the album where it does not decrypt", async () => { + // The same account, backed up by `lib.backup()` limited to album 1, + // "Trip", as `quak backup` cannot be. File 30 is in Trip, so the run + // must store it, from its copy in album 3 that the run otherwise + // skips. + const ente = new FakeEnte(); + ente.putAlbum(1, "Trip", 1); + ente.putFile(1, 30, 1, { corruptKey: true }); + ente.putAlbum(3, "Favorites", 1); + ente.putFile(3, 30, 1); + const lib = await Library.open({ + client: Client.fromJSON(ente.snapshot(), { + fetch: ente.fetch, + retry: { attempts: 1 }, + }), + downloadDirectory: backupDir(), + cacheDirectory: join(root, "cache"), + precacheThumbnails: false, + precacheOriginals: false, + }); + try { + const result = await lib.backup({ + downloadDirectory: backupDir(), + onlyAlbumNames: ["Trip"], + }); + expect(result).toMatchObject({ downloaded: 1, failed: 0 }); + } finally { + await lib.close(); + } + + expect(stored(30)).toBe(true); + expect(failures()).toEqual({}); + }); }); describe("the read commands with records quak cannot decrypt", () => {