aboutsummaryrefslogtreecommitdiff
path: root/network/receivepack
diff options
context:
space:
mode:
authorGravatar Runxi Yu2026-03-28 19:58:37 +0000
committerGravatar Runxi Yu2026-03-28 19:58:37 +0000
commitea8373ed78113af57315ae4523d42dfed3a3b1fe (patch)
tree835f98905046a8e5564cf6057af450fe03035444 /network/receivepack
parentcommon/iowrap: Add io wrappers (diff)
signatureNo signature
network, internal/progress, format/packfile/ingest: Use WriteFlusher
Diffstat (limited to 'network/receivepack')
-rw-r--r--network/receivepack/hook.go3
-rw-r--r--network/receivepack/receivepack.go15
-rw-r--r--network/receivepack/service/hook.go3
-rw-r--r--network/receivepack/service/ingest_quarantine.go9
-rw-r--r--network/receivepack/service/options.go9
5 files changed, 18 insertions, 21 deletions
diff --git a/network/receivepack/hook.go b/network/receivepack/hook.go
index 96027769..22135746 100644
--- a/network/receivepack/hook.go
+++ b/network/receivepack/hook.go
@@ -4,6 +4,7 @@ import (
"context"
"io"
+ "codeberg.org/lindenii/furgit/common/iowrap"
commitgraphread "codeberg.org/lindenii/furgit/format/commitgraph/read"
"codeberg.org/lindenii/furgit/network/receivepack/service"
objectid "codeberg.org/lindenii/furgit/object/id"
@@ -12,7 +13,7 @@ import (
)
type HookIO struct {
- Progress io.Writer
+ Progress iowrap.WriteFlusher
Error io.Writer
}
diff --git a/network/receivepack/receivepack.go b/network/receivepack/receivepack.go
index 1052848e..26fce24c 100644
--- a/network/receivepack/receivepack.go
+++ b/network/receivepack/receivepack.go
@@ -4,7 +4,7 @@ import (
"context"
"io"
- "codeberg.org/lindenii/furgit/network/protocol/pktline"
+ "codeberg.org/lindenii/furgit/common/iowrap"
common "codeberg.org/lindenii/furgit/network/protocol/v0v1/server"
protoreceive "codeberg.org/lindenii/furgit/network/protocol/v0v1/server/receivepack"
"codeberg.org/lindenii/furgit/network/receivepack/service"
@@ -23,7 +23,7 @@ import (
// Labels: Deps-Borrowed.
func ReceivePack(
ctx context.Context,
- w pktline.WriteFlusher,
+ w iowrap.WriteFlusher,
r io.Reader,
opts Options,
) error {
@@ -89,12 +89,10 @@ func ReceivePack(
return err
}
- progressWriter := protoSession.ProgressWriter()
- progressFlush := base.FlushIO
+ progress := protoSession.ProgressWriter()
if req.Capabilities.Quiet {
- progressWriter = io.Discard
- progressFlush = nil
+ progress = iowrap.NopFlush(io.Discard)
}
serviceReq := &service.Request{
@@ -112,14 +110,13 @@ func ReceivePack(
ExistingObjects: opts.ExistingObjects,
CommitGraph: opts.CommitGraph,
ObjectsRoot: opts.ObjectsRoot,
- Progress: progressWriter,
- ProgressFlush: progressFlush,
+ Progress: progress,
PromotedObjectPermissions: translatePromotedObjectPermissions(
opts.PromotedObjectPermissions,
),
Hook: translateHook(opts.Hook),
HookIO: service.HookIO{
- Progress: progressWriter,
+ Progress: progress,
Error: protoSession.ErrorWriter(),
},
})
diff --git a/network/receivepack/service/hook.go b/network/receivepack/service/hook.go
index 66ff0929..7f7b88b5 100644
--- a/network/receivepack/service/hook.go
+++ b/network/receivepack/service/hook.go
@@ -4,6 +4,7 @@ import (
"context"
"io"
+ "codeberg.org/lindenii/furgit/common/iowrap"
commitgraphread "codeberg.org/lindenii/furgit/format/commitgraph/read"
objectid "codeberg.org/lindenii/furgit/object/id"
objectstore "codeberg.org/lindenii/furgit/object/store"
@@ -11,7 +12,7 @@ import (
)
type HookIO struct {
- Progress io.Writer
+ Progress iowrap.WriteFlusher
Error io.Writer
}
diff --git a/network/receivepack/service/ingest_quarantine.go b/network/receivepack/service/ingest_quarantine.go
index 1ed62a73..14083fe1 100644
--- a/network/receivepack/service/ingest_quarantine.go
+++ b/network/receivepack/service/ingest_quarantine.go
@@ -50,11 +50,10 @@ func (service *Service) ingestQuarantine(
req.Pack,
service.opts.Algorithm,
ingest.Options{
- FixThin: true,
- WriteRev: true,
- Base: service.opts.ExistingObjects,
- Progress: service.opts.Progress,
- ProgressFlush: service.opts.ProgressFlush,
+ FixThin: true,
+ WriteRev: true,
+ Base: service.opts.ExistingObjects,
+ Progress: service.opts.Progress,
},
)
if err != nil {
diff --git a/network/receivepack/service/options.go b/network/receivepack/service/options.go
index ab867bce..82c496c3 100644
--- a/network/receivepack/service/options.go
+++ b/network/receivepack/service/options.go
@@ -1,10 +1,10 @@
package service
import (
- "io"
"io/fs"
"os"
+ "codeberg.org/lindenii/furgit/common/iowrap"
commitgraphread "codeberg.org/lindenii/furgit/format/commitgraph/read"
objectid "codeberg.org/lindenii/furgit/object/id"
objectstore "codeberg.org/lindenii/furgit/object/store"
@@ -22,16 +22,15 @@ type PromotedObjectPermissions struct {
//
// Refs and ExistingObjects are required and must be non-nil.
// ObjectsRoot is required if Execute may need to ingest or promote a pack.
-// Progress, ProgressFlush, Hook, and HookIO are optional; when provided they
-// are also borrowed for the duration of Execute.
+// Progress, Hook, and HookIO are optional; when provided they are also
+// borrowed for the duration of Execute.
type Options struct {
Algorithm objectid.Algorithm
Refs refstore.ReadWriteStore
ExistingObjects objectstore.ReadingStore
CommitGraph *commitgraphread.Reader
ObjectsRoot *os.Root
- Progress io.Writer
- ProgressFlush func() error
+ Progress iowrap.WriteFlusher
PromotedObjectPermissions *PromotedObjectPermissions
Hook Hook
HookIO HookIO