diff options
| author | 2026-03-05 18:24:40 +0800 | |
|---|---|---|
| committer | 2026-03-05 19:05:47 +0800 | |
| commit | 57f1818d547f2f1dca38033b4e29f62d89ef80f9 (patch) | |
| tree | 88d55ac38e2427860bf380c8cce42fcb3bb1e9ee /format/pack/ingest/api.go | |
| parent | internal/compress/zlib: Use flate's compression consumed counter (diff) | |
| signature | No signature | |
format/pack/ingest: Init
Diffstat (limited to 'format/pack/ingest/api.go')
| -rw-r--r-- | format/pack/ingest/api.go | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/format/pack/ingest/api.go b/format/pack/ingest/api.go new file mode 100644 index 00000000..9e222c1d --- /dev/null +++ b/format/pack/ingest/api.go @@ -0,0 +1,52 @@ +package ingest + +import ( + "io" + "os" + + "codeberg.org/lindenii/furgit/objectid" + "codeberg.org/lindenii/furgit/objectstore" +) + +// Result describes one successful ingest transaction. +type Result struct { + // PackName is the destination-relative filename of the written .pack. + PackName string + // IdxName is the destination-relative filename of the written .idx. + IdxName string + // RevName is the destination-relative filename of the written .rev. + // + // RevName is empty when writeRev is false. + RevName string + // PackHash is the final pack hash (same hash embedded in .idx/.rev trailers). + PackHash objectid.ObjectID + // ObjectCount is the final object count in the resulting pack. + // + // If thin fixup appends objects, this includes appended base objects. + ObjectCount uint32 + // ThinFixed reports whether thin fixup appended local bases. + ThinFixed bool +} + +// Ingest ingests one pack stream from src into destination. +// +// Ingest performs streaming pack read/write/verification, delta resolution, +// optional thin fixup, then writes .idx and optionally .rev. +// +// destination ownership and lifecycle are managed by the caller. +// Ingest does not perform quarantine promotion/migration. +func Ingest( + src io.Reader, + destination *os.Root, + algo objectid.Algorithm, + fixThin bool, + writeRev bool, + base objectstore.Store, +) (Result, error) { + state, err := newIngestState(src, destination, algo, fixThin, writeRev, base) + if err != nil { + return Result{}, err + } + + return ingest(state) +} |
