Skip to content

Commit c8f6147

Browse files
committed
fix!: client with raw abs path option
1 parent a313d80 commit c8f6147

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module github.com/ipfs/go-ipfs-cmds
33
go 1.20
44

55
require (
6-
github.com/ipfs/boxo v0.8.0
6+
github.com/ipfs/boxo v0.12.0
77
github.com/ipfs/go-log v1.0.5
88
github.com/rs/cors v1.7.0
99
github.com/texttheater/golang-levenshtein v0.0.0-20180516184445-d188e65d659e

go.sum

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs
99
github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
1010
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
1111
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
12-
github.com/ipfs/boxo v0.8.0 h1:UdjAJmHzQHo/j3g3b1bAcAXCj/GM6iTwvSlBDvPBNBs=
13-
github.com/ipfs/boxo v0.8.0/go.mod h1:RIsi4CnTyQ7AUsNn5gXljJYZlQrHBMnJp94p73liFiA=
12+
github.com/ipfs/boxo v0.12.0 h1:AXHg/1ONZdRQHQLgG5JHsSC3XoE4DjCAMgK+asZvUcQ=
13+
github.com/ipfs/boxo v0.12.0/go.mod h1:xAnfiU6PtxWCnRqu7dcXQ10bB5/kvI1kXRotuGqGBhg=
1414
github.com/ipfs/go-log v1.0.5 h1:2dOuUCB1Z7uoczMWgAyDck5JLb72zHzrMnGnCNNbvY8=
1515
github.com/ipfs/go-log v1.0.5/go.mod h1:j0b8ZoR+7+R99LD9jZ6+AJsrzkPbSXbZfGakb5JPtIo=
1616
github.com/ipfs/go-log/v2 v2.1.3/go.mod h1:/8d0SH3Su5Ooc31QlL1WysJhvyOTDCjcCZ9Axpmri6g=
@@ -37,7 +37,7 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+
3737
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
3838
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
3939
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
40-
github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8=
40+
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
4141
github.com/texttheater/golang-levenshtein v0.0.0-20180516184445-d188e65d659e h1:T5PdfK/M1xyrHwynxMIVMWLS7f/qHwfslZphxtGnw7s=
4242
github.com/texttheater/golang-levenshtein v0.0.0-20180516184445-d188e65d659e/go.mod h1:XDKHRm5ThF8YJjx001LtgelzsoaEcvnA7lVWz9EeX3g=
4343
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=

http/client.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ type client struct {
2929
apiPrefix string
3030
headers map[string]string
3131
fallback cmds.Executor
32+
rawAbsPath bool
3233
}
3334

3435
// ClientOpt is an option that can be passed to the HTTP client constructor.
@@ -75,6 +76,13 @@ func ClientWithFallback(exe cmds.Executor) ClientOpt {
7576
}
7677
}
7778

79+
// ClientWithRawAbsPath enables the rawAbspath for [files.NewMultiFileReader].
80+
func ClientWithRawAbsPath(rawAbsPath bool) ClientOpt {
81+
return func(c *client) {
82+
c.rawAbsPath = rawAbsPath
83+
}
84+
}
85+
7886
// NewClient constructs a new HTTP-backed command executor.
7987
func NewClient(address string, opts ...ClientOpt) cmds.Executor {
8088
if !strings.HasPrefix(address, "http://") {
@@ -161,10 +169,10 @@ func (c *client) toHTTPRequest(req *cmds.Request) (*http.Request, error) {
161169
// However, such is life.
162170
fileReader = files.NewMultiFileReader(files.NewMapDirectory(map[string]files.Node{
163171
"stdin": files.NewReaderFile(bodyArgs),
164-
}), true)
172+
}), true, c.rawAbsPath)
165173
reader = fileReader
166174
} else if req.Files != nil {
167-
fileReader = files.NewMultiFileReader(req.Files, true)
175+
fileReader = files.NewMultiFileReader(req.Files, true, c.rawAbsPath)
168176
reader = fileReader
169177
}
170178

0 commit comments

Comments
 (0)