aboutsummaryrefslogtreecommitdiff
path: root/network/receivepack/service/execute.go
diff options
context:
space:
mode:
authorGravatar Runxi Yu2026-03-30 19:51:58 +0000
committerGravatar Runxi Yu2026-03-30 19:57:33 +0000
commitda621b97d0aa209e7e502e9e898e0a7a89857216 (patch)
treec1484d878f85216ebf108e1e72136ccdabe4156f /network/receivepack/service/execute.go
parentrepository: Use dual (diff)
signatureNo signature
network/receivepack: Use dual
Diffstat (limited to 'network/receivepack/service/execute.go')
-rw-r--r--network/receivepack/service/execute.go27
1 files changed, 11 insertions, 16 deletions
diff --git a/network/receivepack/service/execute.go b/network/receivepack/service/execute.go
index 5b00dba5..08177873 100644
--- a/network/receivepack/service/execute.go
+++ b/network/receivepack/service/execute.go
@@ -2,9 +2,9 @@ package service
import (
"context"
- "os"
"codeberg.org/lindenii/furgit/internal/utils"
+ objectstore "codeberg.org/lindenii/furgit/object/store"
)
// Execute validates one receive-pack request, optionally ingests its pack into
@@ -15,23 +15,17 @@ func (service *Service) Execute(ctx context.Context, req *Request) (*Result, err
result := &Result{
Commands: make([]CommandResult, 0, len(req.Commands)),
}
+ var err error
- var (
- quarantineName string
- quarantineRoot *os.Root
- err error
- )
-
- quarantineName, quarantineRoot, ok := service.ingestQuarantine(result, req.Commands, req)
+ quarantine, ok := service.ingestQuarantine(result, req.Commands, req)
if !ok {
return result, nil
}
- if quarantineRoot != nil {
- defer func() {
- _ = quarantineRoot.Close()
- _ = service.opts.ObjectsRoot.RemoveAll(quarantineName)
- }()
+ if quarantine != nil {
+ defer func(q objectstore.Quarantine) {
+ _ = q.Discard()
+ }(quarantine)
}
for _, command := range req.Commands {
@@ -51,7 +45,7 @@ func (service *Service) Execute(ctx context.Context, req *Request) (*Result, err
ctx,
req,
req.Commands,
- quarantineName,
+ quarantine,
)
if !ok {
fillCommandErrors(result, req.Commands, errText)
@@ -79,12 +73,12 @@ func (service *Service) Execute(ctx context.Context, req *Request) (*Result, err
return result, nil
}
- if req.PackExpected && quarantineRoot != nil {
+ if req.PackExpected && quarantine != nil {
// Git migrates quarantined objects into permanent storage immediately
// before starting ref updates.
utils.BestEffortFprintf(service.opts.Progress, "promoting quarantine...\r")
- err = service.promoteQuarantine(quarantineName, quarantineRoot)
+ err := quarantine.Promote()
if err != nil {
utils.BestEffortFprintf(service.opts.Progress, "promoting quarantine: failed: %v.\n", err)
@@ -94,6 +88,7 @@ func (service *Service) Execute(ctx context.Context, req *Request) (*Result, err
return result, nil
}
+ quarantine = nil
utils.BestEffortFprintf(service.opts.Progress, "promoting quarantine: done.\n")
}