{"draft":null,"from":180,"to":181,"files":[{"path":"server/src/push.ts","added":17,"removed":10,"diff":"--- a/server/src/push.ts\n+++ b/server/src/push.ts\n@@ -179,21 +179,16 @@\n \t// Each file goes into the tree as a blob with its mode (#27): 100755 for exec, 120000 for a link, whose blob is\n \t// its target.\n \tconst enc = new TextEncoder();\n-\tfor (const path of Object.keys(shared.files)) {\n-\t\tconst mode = shared.modes?.[path];\n-\t\tconst link = typeof mode?.link === \"string\" ? mode.link : null;\n-\t\tconst bytes = enc.encode(link ?? shared.files[path]!);\n-\t\tawait put(path, bytes, link !== null ? \"120000\" : mode?.exec ? \"100755\" : \"100644\", await blobOid(bytes));\n-\t}\n \tconst agent = shared.last?.agent ?? \"abso\";\n \tconst author = { name: agent, email: `${agent}@abso.invalid` };\n \tconst committer = { name: \"abso\", email: \"abso@abso.invalid\" };\n \tconst say = (p: string) => `${shared.last?.message ?? \"Start the project\"}${p}\\n\\nabso-version: ${shared.version}\\n`;\n \tlet parent = head;\n-\t// A part holds what's written so far, and the last push's entries for the binary files not reached yet.\n+\t// A part holds what's written so far and preserves old entries for files not reached yet.\n \tconst commitNow = async (message: string) => {\n \t\tconst files = new Map(now);\n-\t\tfor (const [path, f] of old.files) if (!files.has(path) && path in blobs) files.set(path, f);\n+\t\tfor (const [path, f] of old.files)\n+\t\t\tif (!files.has(path) && (path in blobs || path in shared.files)) files.set(path, f);\n \t\tconst tree = await writeTrees(fs, dir, files, old.trees, changed);\n \t\tparent = await git.commit({\n \t\t\tcache,\n@@ -208,12 +203,24 @@\n \t\t});\n \t\treturn parent;\n \t};\n-\t// Binary files (#27) aren't in files: their bytes come from the blob store.\n-\t// Artifacts refuses a push much over 20 MB, so when the new blobs add up\n+\t// Artifacts refuses a push much over 20 MB, so when new text or binary blobs add up\n \t// to more than PUSH_BATCH, the earlier ones go in commits of their own\n \t// first. Every part carries abso-version, so intake never takes them in.\n \tlet pending = 0;\n \tlet parts = 0;\n+\tfor (const path of Object.keys(shared.files)) {\n+\t\tconst mode = shared.modes?.[path];\n+\t\tconst link = typeof mode?.link === \"string\" ? mode.link : null;\n+\t\tconst bytes = enc.encode(link ?? shared.files[path]!);\n+\t\tconst oid = await blobOid(bytes);\n+\t\tconst fresh = old.files.get(path)?.oid !== oid;\n+\t\tif (fresh && pending > 0 && pending + bytes.byteLength > PUSH_BATCH) {\n+\t\t\tawait part(await commitNow(say(` (part ${++parts})`)));\n+\t\t\tpending = 0;\n+\t\t}\n+\t\tif (fresh) pending += bytes.byteLength;\n+\t\tawait put(path, bytes, link !== null ? \"120000\" : mode?.exec ? \"100755\" : \"100644\", oid);\n+\t}\n \tfor (const [path, sha] of Object.entries(blobs)) {\n \t\tconst bytes = readBlob(sha);\n \t\tif (!bytes) throw new Error(`${path}: blob ${sha} is missing from the project's store`);"}],"unmatched":[]}