From 57f1818d547f2f1dca38033b4e29f62d89ef80f9 Mon Sep 17 00:00:00 2001 From: Runxi Yu Date: Thu, 5 Mar 2026 18:24:40 +0800 Subject: format/pack/ingest: Init --- format/pack/ingest/api.go | 52 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 format/pack/ingest/api.go (limited to 'format/pack/ingest/api.go') 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) +} -- cgit v1.3.1-10-gc9f91