Live photo download no longer removes what was at its destination
check / check (push) Failing after 47s

The image and video are renamed into place, and the rename already
replaces the image's name, so the removal and the test that planted a
ZIP there are gone, along with the comments describing it.

Adds a test for a live photo the content cache recorded with no video,
because it opened before knowing the file is a live photo while no JSON
file named its image and video: original() fetches both again and writes
the JSON file. The comment on that check now names this case.

Model: opus-5-5
This commit is contained in:
2026-10-01 23:18:16 +00:00
parent 44b2859877
commit 5d11889e1a
4 changed files with 37 additions and 15 deletions
+30
View File
@@ -596,6 +596,36 @@ describe("ContentCache live photos", () => {
expect(second!.pathsFor(5)).toEqual({});
});
it("fetches a live photo's image and video again when the cache opened before knowing it is a live photo and no JSON file names them", async () => {
const { file: live, body } = await asLivePhoto(file(5, "IMG_5.HEIC"));
mkdirSync(originals(), { recursive: true });
writeFileSync(join(originals(), "5.heic"), "an image");
writeFileSync(join(originals(), "5.mov"), "a video");
const cache = cacheOf([live], new Map([[5, body]]));
// Opened without being told that file 5 is a live photo, the cache
// records one of the two files as its original, with no video.
await cache.open();
const events: string[] = [];
const result = await cache.original(5, {
onProgress: (e) => events.push(e.status),
});
expect(events.at(-1)).toBe("done");
expect(result).toEqual({
path: join(originals(), "5.heic"),
videoPath: join(originals(), "5.mov"),
bytes: IMAGE.length,
});
expect(readFileSync(result.path)).toEqual(Buffer.from(IMAGE));
expect(readFileSync(result.videoPath!)).toEqual(Buffer.from(VIDEO));
expect(
JSON.parse(
readFileSync(join(originals(), "5.livephoto.json"), "utf-8"),
),
).toEqual({ image: "5.heic", video: "5.mov" });
});
it.each(["missing", "empty"])(
"fetches a live photo again when the video its JSON file names is %s",
async (state) => {