aboutsummaryrefslogtreecommitdiff
path: root/packfile/ingest/api.go
diff options
context:
space:
mode:
authorGravatar Runxi Yu2026-03-22 22:46:10 +0000
committerGravatar Runxi Yu2026-03-22 22:46:10 +0000
commitd2d3ce370816d178cc0beb4271123ee37d07657c (patch)
tree728f074457ed49a676d5c3b77d69b40d40021241 /packfile/ingest/api.go
parentrefstore, repository: Ownership/lifetimes fix (diff)
signatureNo signature
packfile/ingest: Document lifecycle of pack ingest better
Diffstat (limited to 'packfile/ingest/api.go')
-rw-r--r--packfile/ingest/api.go21
1 files changed, 12 insertions, 9 deletions
diff --git a/packfile/ingest/api.go b/packfile/ingest/api.go
index 040e8d77..6d4437e0 100644
--- a/packfile/ingest/api.go
+++ b/packfile/ingest/api.go
@@ -68,6 +68,8 @@ type DiscardResult struct {
}
// Pending is one started ingest operation awaiting Continue or Discard.
+//
+// Exactly one of Continue or Discard may be called.
type Pending struct {
reader *bufio.Reader
algo objectid.Algorithm
@@ -110,11 +112,13 @@ func (pending *Pending) Header() HeaderInfo {
}
// Continue ingests the pack stream into destination and writes pack artifacts.
+//
+// Continue is terminal. Further use of pending is undefined behavior.
+//
+// Artifacts are published under content-addressed final names derived from the
+// resulting pack hash. If those final names already exist, Continue treats that
+// as success and removes its temporary files.
func (pending *Pending) Continue(destination *os.Root) (Result, error) {
- if pending.finalized {
- return Result{}, ErrAlreadyFinalized
- }
-
pending.finalized = true
if pending.header.ObjectCount == 0 {
@@ -136,12 +140,11 @@ func (pending *Pending) Continue(destination *os.Root) (Result, error) {
return ingest(state)
}
-// Discard consumes and verifies one zero-object pack stream without writing files.
+// Discard consumes and verifies one zero-object pack stream without writing
+// files.
+//
+// Discard is terminal. Further use of pending is undefined behavior.
func (pending *Pending) Discard() (DiscardResult, error) {
- if pending.finalized {
- return DiscardResult{}, ErrAlreadyFinalized
- }
-
pending.finalized = true
if pending.header.ObjectCount != 0 {