Test: a damaged list in metadata.json, and records that stop decrypting
check / check (push) Waiting to run

A metadata.json whose list of what the refresh could not decrypt is
damaged must load as an empty store. A backup after an album and a
file's copy stop decrypting removes the album's folder and JSON and the
file's link in its album, and keeps the originals.

Model: opus-5-5
This commit is contained in:
2026-10-14 03:57:04 +00:00
parent f75816a0da
commit 3f03689ae4
2 changed files with 61 additions and 0 deletions
+23
View File
@@ -172,6 +172,29 @@ describe("MetadataStore", () => {
expect(store.listCollections()).toEqual([]);
});
it("loads an empty store when the list of what the refresh could not decrypt is damaged", async () => {
// A backup reads that list on every run, so a damaged one that loaded
// would fail every backup until the cache was deleted. A string is
// damaged too, though JavaScript can loop over its characters.
mkdirSync(join(dir, "cache"), { recursive: true });
for (const undecryptable of [{}, "not a list", [1]]) {
writeFileSync(
path,
JSON.stringify({
schemaVersion: METADATA_SCHEMA_VERSION,
userID: 42,
collectionsSinceTime: 0,
collections: [],
files: [],
undecryptable,
}),
);
const store = await MetadataStore.load(path);
expect(store.userID).toBe(0);
expect(store.listUndecryptable()).toEqual([]);
}
});
it("creates the directory 0700 and the file 0600", async () => {
const store = await MetadataStore.load(path);
store.putCollection(sampleCollection());