Remove the content cache's handling of an earlier version's live-photo ZIP (closes #151)
check / check (push) Failing after 55s

quak keeps no handling of old data. The content cache no longer checks
whether a live photo's file with no JSON file naming it is a ZIP an
earlier version cached, and no longer removes it; such a file is left
alone, as any other one already was. The README sentences and the tests
about that ZIP are gone, and one download test no longer names it in its
title. How a live photo is stored and served today is unchanged.

Model: opus-5-5
This commit is contained in:
2026-10-01 22:44:37 +00:00
parent 10afa7a7f4
commit 44b2859877
6 changed files with 11 additions and 126 deletions
+5 -38
View File
@@ -29,14 +29,7 @@
// the cache does not count as saved there, but is copied there rather than
// fetched again.
import {
closeSync,
existsSync,
openSync,
readFileSync,
readSync,
statSync,
} from "node:fs";
import { existsSync, readFileSync, statSync } from "node:fs";
import {
chmod,
copyFile,
@@ -281,25 +274,6 @@ const fileSize = (path: string): number | undefined => {
const hasContent = (path: string | undefined): boolean =>
path !== undefined && (fileSize(path) ?? 0) > 0;
// Whether the file at `path` begins as a ZIP does, with `PK\x03\x04`. False
// when it cannot be read.
const isZip = (path: string): boolean => {
try {
const fd = openSync(path, "r");
try {
const head = Buffer.alloc(4);
return (
readSync(fd, head, 0, 4, 0) === 4 &&
head.toString("latin1") === "PK\x03\x04"
);
} finally {
closeSync(fd);
}
} catch {
return false;
}
};
// A live photo's image and video are named with the extensions from inside its
// ZIP, so their names alone do not say which is which. Wherever the cache or a
// save path stores one, a JSON file of this name beside them names both.
@@ -713,8 +687,7 @@ export class ContentCache implements PhotoContent, ThumbnailsAPI {
await this.touch(cached.path);
return { ...cached, bytes: size, cached: true };
}
// A recorded file that has since gone, or a live photo an earlier
// version stored as one ZIP, re-fetches below.
// A recorded file that has since gone re-fetches below.
known.delete(fileID);
}
@@ -983,20 +956,14 @@ export class ContentCache implements PhotoContent, ThumbnailsAPI {
if (id === undefined || !existsSync(path)) continue;
// A live photo's image and video are one entry, as the JSON file
// beside them names them. A live photo's file with no such JSON
// file is not its original. If it is a ZIP, it is the one an
// earlier version stored under the image's name, and is removed.
// Any other is left alone: another process may have just stored
// it and not yet written the JSON file.
// file is not its original and is left alone: another process may
// have just stored it and not yet written the JSON file.
const livePhoto = names.has(livePhotoJSONName(String(id)))
? readLivePhotoJSON(dir, String(id))
: undefined;
if (livePhoto !== undefined) {
into.set(id, livePhoto);
} else if (isLivePhoto(id)) {
if (isZip(path)) {
await rm(path, { force: true }).catch(() => undefined);
}
} else {
} else if (!isLivePhoto(id)) {
into.set(id, { path });
}
}