Remove the content cache's handling of an earlier version's live-photo ZIP (closes #151)
check / check (push) Failing after 55s
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:
@@ -1883,7 +1883,7 @@ describe("downloadFile live photos", () => {
|
||||
expect(readdirSync(t.dir).sort()).toEqual(["f.JPG", "f.bin"]);
|
||||
});
|
||||
|
||||
it("replaces what was at the destination, such as an earlier ZIP of the two", async () => {
|
||||
it("replaces what was at the destination", async () => {
|
||||
const t = setup(livePhotoZip(), livePhoto);
|
||||
writeFileSync(t.outPath, livePhotoZip());
|
||||
|
||||
|
||||
@@ -176,52 +176,6 @@ describe("Library content wiring", () => {
|
||||
await lib.close();
|
||||
});
|
||||
|
||||
it("removes a live photo's ZIP an earlier version cached when it opens, and precaches its image and video", async () => {
|
||||
const { file: live, body } = await asLivePhoto(file(1, 1));
|
||||
class LiveClient extends MockClient {
|
||||
override async filesSince(): Promise<FilesPage> {
|
||||
return { files: [live], deleted: [], cursor: 1 };
|
||||
}
|
||||
}
|
||||
const originals = join(root, "cache", "originals");
|
||||
const open = (opts: Partial<LibraryOptions>): Promise<Library> =>
|
||||
Library.open({
|
||||
client: new LiveClient(),
|
||||
cacheDirectory: join(root, "cache"),
|
||||
contentSource: cdnSource(new Map([[1, body]])),
|
||||
refreshIntervalSeconds: 3600,
|
||||
precacheThumbnails: false,
|
||||
precacheOriginals: false,
|
||||
...opts,
|
||||
});
|
||||
// A first run records the library, so the next one knows that file 1
|
||||
// is a live photo when it opens the cache.
|
||||
await (await open({})).close();
|
||||
writeFileSync(join(originals, "1.jpg"), livePhotoZip());
|
||||
|
||||
let precached!: () => void;
|
||||
const done = new Promise<void>((r) => (precached = r));
|
||||
const lib = await open({
|
||||
precacheOriginals: true,
|
||||
onProgress: (e) => {
|
||||
if (e.operation === "precacheOriginals" && e.status === "done")
|
||||
precached();
|
||||
},
|
||||
});
|
||||
expect(existsSync(join(originals, "1.jpg"))).toBe(false);
|
||||
await done;
|
||||
|
||||
expect(readdirSync(originals).sort()).toEqual([
|
||||
"1.heic",
|
||||
"1.livephoto.json",
|
||||
"1.mov",
|
||||
]);
|
||||
expect(lib.photos.byID({ fileID: 1 })!.record().originalPath).toBe(
|
||||
join(originals, "1.heic"),
|
||||
);
|
||||
await lib.close();
|
||||
});
|
||||
|
||||
it("throws from content methods when opened without a content source", async () => {
|
||||
const lib = await Library.open({
|
||||
client: new MockClient(),
|
||||
|
||||
@@ -566,43 +566,6 @@ describe("ContentCache live photos", () => {
|
||||
expect(events).toEqual(["skipped"]);
|
||||
});
|
||||
|
||||
it("replaces a live photo an earlier version stored as a ZIP under the image's name", async () => {
|
||||
const { file: live, body } = await asLivePhoto(file(5, "IMG_5.HEIC"));
|
||||
mkdirSync(originals(), { recursive: true });
|
||||
writeFileSync(join(originals(), "5.HEIC"), livePhotoZip());
|
||||
const cache = cacheOf([live], new Map([[5, body]]));
|
||||
// Opened without being told that file 5 is a live photo, the cache
|
||||
// records the ZIP, and does not serve it.
|
||||
await cache.open();
|
||||
|
||||
const result = await cache.original(5);
|
||||
|
||||
expect(result.videoPath).toBe(join(originals(), "5.mov"));
|
||||
expect(readdirSync(originals()).sort()).toEqual([
|
||||
"5.heic",
|
||||
"5.livephoto.json",
|
||||
"5.mov",
|
||||
]);
|
||||
});
|
||||
|
||||
it("removes a live photo's ZIP an earlier version stored when it opens, so the precache fetches the image and video", async () => {
|
||||
const { file: live, body } = await asLivePhoto(file(5, "IMG_5.HEIC"));
|
||||
mkdirSync(originals(), { recursive: true });
|
||||
writeFileSync(join(originals(), "5.HEIC"), livePhotoZip());
|
||||
const cache = cacheOf([live], new Map([[5, body]]));
|
||||
|
||||
await cache.open((fileID) => fileID === 5);
|
||||
|
||||
expect(readdirSync(originals())).toEqual([]);
|
||||
expect(cache.pathsFor(5)).toEqual({});
|
||||
const [fetched] = await cache.ensureOriginals({ fileIDs: [5] });
|
||||
expect(fetched).toEqual({
|
||||
fileID: 5,
|
||||
path: join(originals(), "5.heic"),
|
||||
});
|
||||
expect(cache.pathsFor(5)).toEqual({ originalPath: fetched!.path });
|
||||
});
|
||||
|
||||
it("leaves the image and video another process has just stored when it opens before their JSON file is written", async () => {
|
||||
const { file: live, body } = await asLivePhoto(file(5, "IMG_5.HEIC"));
|
||||
const server = cdnSource(new Map([[5, body]]));
|
||||
|
||||
Reference in New Issue
Block a user