a repo's state names each link once, so a big folder's pages don't make it tens of MB to write and read back
Signed-off-by: dawn <90008@klbr.net>
3 unmodified lines456788910111263 unmodified lines3 unmodified linesimport path from "node:path";import { latestPath, ROUTES } from "./shared.mjs";
// a bump means no saved page can be trustedexport const RENDERER_FORMAT = 4;export const RENDERER_FORMAT = 5;
export const tokenOf = (did) => createHash("sha256").update(did).digest("hex").slice(0, 32);
// svfe's url for a repo's owner: the handle, or the did when it has none63 unmodified lines275 unmodified linesExpand all276277278279280280281282283284329 unmodified linesExpand all61461561661761861962062162262362462562662762862963063163263362463463563663763863990 unmodified lines275 unmodified linesExpand all const prior = work === "all" ? null : saved; const pages = prior ? prior.pages : {}; for (const page of Object.values(pages)) { page.deps = page.deps.map(intern); page.links = page.links?.map(intern); page.links = page.links?.map((at) => intern(prior.routes[at])); } // routes left out with the reads that failed them, retried when one of those changes const left = prior ? (prior.left ?? {}) : {}; const dirty = new Set(prior ? work : []);329 unmodified linesExpand all stats.over_budget = over.size; checkCurrent();
await publish(repo, savedAliases, genDir, tmpDir); // a page's links are places in one list of routes: a folder's pages all link the same // siblings, and written out in full they made a big folder's state tens of MB const routes = []; const placeOf = new Map(); const placed = (route) => { if (!placeOf.has(route)) placeOf.set(route, routes.push(route) - 1); return placeOf.get(route); }; const saving = {}; for (const [route, page] of Object.entries(pages)) saving[route] = { ...page, links: page.links?.map(placed) }; await atomicJson(stateFile, { did: repo.did, prefix, aliases: aliasesOf(repo), format: RENDERER_FORMAT, generation: hook.generation, pages, pages: saving, routes, left, over: [...over].sort(), latest, counts: counts.keys90 unmodified lines