{"draft":null,"from":4,"to":318,"files":[{"path":"worker/project/view-changes.ts","added":49,"removed":5,"diff":"--- a/worker/project/view-changes.ts\n+++ b/worker/project/view-changes.ts\n@@ -1,9 +1,10 @@\n-import type { View } from \"../../src/engine/index.ts\";\n+import { createHash } from \"node:crypto\";\n+import type { ReadView } from \"../../src/engine/index.ts\";\n import { ProjectError } from \"./project-error.ts\";\n import type { FileChange, Mode, Modes } from \"./project-types.ts\";\n \n /** The listed files whose text differs between two views, before and after. */\n-export function changesBetween(before: View, after: View, files: Iterable<string>): FileChange[] {\n+export function changesBetween(before: ReadView, after: ReadView, files: Iterable<string>): FileChange[] {\n \tconst out: FileChange[] = [];\n \tfor (const path of [...new Set(files)].toSorted()) {\n \t\tconst b = before.hasFile(path) ? before.text(path) : null;\n@@ -18,8 +19,51 @@\n \treturn out;\n }\n \n+/** A changed file's text or blob, summed up: its size in UTF-8 bytes and its SHA-256, or a blob's hash. */\n+export type FileSummary = { size: number; sha256: string } | { blob: string };\n+\n+/**\n+ * changesBetween without the texts (abso issue 680, compare's summary): each changed file before and after as its size\n+ * and SHA-256, or its blob's hash for a binary file. Each text is read, summed up and let go, so a compare of thousands\n+ * of files never holds them all.\n+ */\n+export function summariesBetween(\n+\tbefore: ReadView,\n+\tafter: ReadView,\n+\tfiles: Iterable<string>,\n+): {\n+\tpath: string;\n+\tbefore: FileSummary | null;\n+\tafter: FileSummary | null;\n+\tmode?: { before: Mode; after: Mode };\n+\tblob?: { before: string | null; after: string | null };\n+}[] {\n+\tconst sum = (view: ReadView, path: string): FileSummary | null => {\n+\t\tif (!view.hasFile(path)) return null;\n+\t\tconst blob = view.attrs(path).blob;\n+\t\tif (blob !== null) return { blob };\n+\t\tconst text = view.text(path);\n+\t\treturn { size: Buffer.byteLength(text, \"utf8\"), sha256: createHash(\"sha256\").update(text, \"utf8\").digest(\"hex\") };\n+\t};\n+\tconst out: ReturnType<typeof summariesBetween> = [];\n+\tfor (const path of [...new Set(files)].toSorted()) {\n+\t\tif (!differs(before, after, path)) continue;\n+\t\tconst mode = modeChange(before, after, path);\n+\t\tconst bb = before.attrs(path).blob;\n+\t\tconst ab = after.attrs(path).blob;\n+\t\tout.push({\n+\t\t\tpath,\n+\t\t\tbefore: sum(before, path),\n+\t\t\tafter: sum(after, path),\n+\t\t\t...(mode ? { mode } : {}),\n+\t\t\t...(bb !== ab ? { blob: { before: bb, after: ab } } : {}),\n+\t\t});\n+\t}\n+\treturn out;\n+}\n+\n /** Whether a file differs between two views: its text, its mode, or its blob (what changesBetween lists). */\n-export function differs(before: View, after: View, path: string): boolean {\n+export function differs(before: ReadView, after: ReadView, path: string): boolean {\n \tconst had = before.hasFile(path);\n \tif (had !== after.hasFile(path)) return true;\n \tif (had && !before.sameText(path, after)) return true;\n@@ -29,7 +73,7 @@\n }\n \n /** A file's executable bit and link target, before and after, when either changed. */\n-export function modeChange(before: View, after: View, path: string): { before: Mode; after: Mode } | undefined {\n+export function modeChange(before: ReadView, after: ReadView, path: string): { before: Mode; after: Mode } | undefined {\n \tconst b = before.attrs(path);\n \tconst a = after.attrs(path);\n \tif (b.exec === a.exec && b.link === a.link) return undefined;\n@@ -37,7 +81,7 @@\n }\n \n /** Every executable file and link in a view. */\n-export function modesOf(view: View): Modes {\n+export function modesOf(view: ReadView): Modes {\n \tconst out: Modes = {};\n \tfor (const path of view.paths()) {\n \t\tconst a = view.attrs(path);"}],"unmatched":[]}