1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
package service
import (
"os"
"codeberg.org/lindenii/furgit/format/pack/ingest"
)
func (service *Service) ingestQuarantine(
result *Result,
commands []Command,
req *Request,
) (string, *os.Root, bool) {
if !req.PackExpected {
return "", nil, true
}
if req.Pack == nil {
result.UnpackError = "missing pack stream"
fillCommandErrors(result, commands, "missing pack stream")
return "", nil, false
}
if service.opts.ObjectsRoot == nil {
result.UnpackError = "objects root not configured"
fillCommandErrors(result, commands, "objects root not configured")
return "", nil, false
}
quarantineName, quarantineRoot, err := service.createQuarantineRoot()
if err != nil {
result.UnpackError = err.Error()
fillCommandErrors(result, commands, err.Error())
return "", nil, false
}
quarantinePackRoot, err := service.openQuarantinePackRoot(quarantineRoot)
if err != nil {
result.UnpackError = err.Error()
fillCommandErrors(result, commands, err.Error())
_ = quarantineRoot.Close()
_ = service.opts.ObjectsRoot.RemoveAll(quarantineName)
return "", nil, false
}
ingested, err := ingest.Ingest(
req.Pack,
quarantinePackRoot,
service.opts.Algorithm,
true,
true,
service.opts.ExistingObjects,
)
_ = quarantinePackRoot.Close()
if err != nil {
result.UnpackError = err.Error()
fillCommandErrors(result, commands, err.Error())
_ = quarantineRoot.Close()
_ = service.opts.ObjectsRoot.RemoveAll(quarantineName)
return "", nil, false
}
result.Ingest = &ingested
return quarantineName, quarantineRoot, true
}
|