| author | Divy Srivastava <me@littledivy.com> | 2026-08-20 06:38:52 +0530 |
|---|---|---|
| committer | Divy Srivastava <me@littledivy.com> | 2026-08-20 06:38:52 +0530 |
| commit | 9830de2d396dabedf9caf940581c84f28dcc4efc (patch) | |
| tree | a964283f1efcb33ffe654b0c40493c2a4040799d | |
| parent | c75815bb552c4f79c62081e25a2ee45d1bff6cb0 (diff) | |
| download | dgit-9830de2d39.tar.gz zip | |
Diffstat
| package-lock.json | +2 | -2 |
| package.json | +1 | -1 |
| src/git/packstore.ts | +8 | -7 |
| src/repo.ts | +1 | -1 |
4 files changed, 12 insertions(+), 11 deletions(-)
diff --git a/package-lock.json b/package-lock.json @@ -1,12 +1,12 @@ { "name": "dgit", - "version": "0.0.6", + "version": "0.0.7", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "dgit", - "version": "0.0.6", + "version": "0.0.7", "dependencies": { "pako": "^2.1.0" }, diff --git a/package.json b/package.json @@ -1,6 +1,6 @@ { "name": "durable-git", - "version": "0.0.6", + "version": "0.0.7", "description": "Durable git: a git server as a Cloudflare Durable Object. Smart HTTP, a cgit-style web interface, pluggable auth, push events, and a typed content API.", "type": "module", "main": "src/mod.ts", diff --git a/src/git/packstore.ts b/src/git/packstore.ts @@ -482,8 +482,9 @@ opts: { maxBytes: number; /** push body size (content-length ~= pack size); packs this size are - * stored in R2 when a bucket is bound, else in SQLite. Absent/unknown - * (chunked pushes) picks SQLite — the small-push-fast bias. */ + * stored in R2 when a bucket is bound, else in SQLite. Absent means the + * client went chunked, which git only does above ~1MB (http.postBuffer) + * — so unknown size picks R2, the safe side for the 10GB SQLite cap. */ sizeHint?: number; cache: ObjCache; onProgress?: (msg: string) => void; @@ -534,14 +535,14 @@ console.log(`[ingest pack ${packId} +${Math.round((Date.now() - started) / 1000)}s] ${msg.trim()}`); }; - // storage backend: a large pack (sizeHint >= R2_PACK_MIN_BYTES) with an R2 - // binding streams its bytes to raw/<repo>/<packId> via multipart and only the - // index stays in SQLite; small packs (and any push without the binding or with - // unknown length) go to pack_data as before. Prime the backend cache now — before + // storage backend: with an R2 binding, a large (sizeHint >= R2_PACK_MIN_BYTES) + // or unknown-length (chunked, so >1MB) pack streams its bytes to + // raw/<repo>/<packId> via multipart and only the index stays in SQLite; small + // declared-length packs go to pack_data. Prime the backend cache now — before // pack_meta exists — so phase B/C readRaw hits the right source. A refused // multipart begin (celld makes createMultipartUpload throw) degrades to SQLite. let capture: MultipartCapture | null = null; - const wantR2 = this.r2 !== null && opts.sizeHint !== undefined && opts.sizeHint >= R2_PACK_MIN_BYTES; + const wantR2 = this.r2 !== null && (opts.sizeHint === undefined || opts.sizeHint >= R2_PACK_MIN_BYTES); if (this.r2 && wantR2) { const mp = await beginRawMultipart(this.r2.bucket, this.rawKey(packId)); if (mp) capture = new MultipartCapture(mp); diff --git a/src/repo.ts b/src/repo.ts @@ -768,7 +768,7 @@ // real Workers the whole isolate has a hard 128MB, so stay small there const budget = typeof caches !== "undefined" ? 16 * 1024 * 1024 : 512 * 1024 * 1024; // content-length ~= pack size; it selects the R2-vs-SQLite backend before - // the first byte lands. Absent/unknown (chunked) leaves it undefined → SQLite. + // the first byte lands. Absent (chunked, i.e. a >1MB push) → undefined → R2. const declared = parseInt(req.headers.get("content-length") ?? "", 10); await this.store.packs.ingest(firstPackBytes, reader, { maxBytes, |