Artifact c550d1fc492bbf3f92046990d228400d5e217dd836d979ac504b4d052fb86fc1:
- File
internal/blob/doc.go
— part of check-in
[cc42ad8829]
at
2026-07-23 09:52:23
on branch trunk
— sync: store received wire frames verbatim instead of re-encoding (#132)
* fix: store received wire frames verbatim instead of re-encoding
Clone reproduced content correctly but not bytes: the receive path decompressed every cfile frame and re-compressed it with blob.Compress's unparameterized zlib writer, so a clone's blob.content never matched its source's — about 0.5% larger on the wapp corpus, purely from re-encoding frames that were already correctly encoded on the wire.
xfer's cfile decoder now hands back StoredBlob alongside the decompressed Content: the same bytes recast into Fossil's on-disk blob format ([4-byte BE size][zlib data]) without a second zlib pass — verbatim when the wire already sent that format (Fossil's send_compressed_file case), or the received zlib stream with a length prefix bolted on when it didn't (our own encoder's plain-zlib case). storeReceivedFile/storeDeltaContent/ storeResolvedContent and blob.StoreDeltaRaw thread that through via a new blob.EncodeForStorage helper, which writes the verbatim bytes when given and only falls back to Compress when there's nothing to preserve — covering both the clone/pull and server-push receive paths.
Locally authored content (never received over the wire) always takes the Compress fallback, so #71's deltification policy is untouched. The clone BUGGIFY corruption test drops storedBlob alongside the corrupted content it's exercising, so verbatim storage can't mask the corruption it exists to catch.
Adds a corpus-level regression test cloning a real multi-revision fossil repo and asserting sum(length(content)) matches between source and clone.
* test: use RequireFossilBin instead of removed HasFossil helper
testutil.HasFossil was removed upstream in favor of RequireFossilBin; this test's skip guard needed the same update to compile against current main. (user: [email protected], size: 1190) [annotate] [blame] [check-ins using]
// Package blob handles content-addressed blob storage in Fossil // repository databases. // // Fossil's blob format is a 4-byte big-endian uncompressed-size prefix // followed by zlib-compressed data. [Compress] and [Decompress] handle // this encoding transparently. // // [Store] compresses content, computes its SHA1 hash, and inserts it // into the blob table. [Load] retrieves and decompresses a blob by RID. // [StoreDeltaRaw] stores content that arrived over the wire already // delta-encoded, without expanding it. [EncodeForStorage] is the shared // decision point for whether a receive path can skip [Compress] entirely // and write already-encoded wire bytes straight to blob.content. // // This package does not decide what gets delta-encoded. Deltifying an // artifact that is already stored means rewriting an existing row, not // inserting a new one, and the decision needs to expand content, which // this package cannot do without importing internal/content. Both live // in content.Deltify, which is the only place the policy is stated. // [StoreDelta] inserts a new row as a delta and has no callers outside // tests; it is not the commit path's primitive. package blob