diff --git a/go.mod b/go.mod index 7f39a21..4e8a657 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/ipfs/go-ipfs-cmds go 1.20 require ( - github.com/ipfs/boxo v0.8.0 + github.com/ipfs/boxo v0.12.0 github.com/ipfs/go-log v1.0.5 github.com/rs/cors v1.7.0 github.com/texttheater/golang-levenshtein v0.0.0-20180516184445-d188e65d659e diff --git a/go.sum b/go.sum index 46cc651..a2817a5 100644 --- a/go.sum +++ b/go.sum @@ -9,8 +9,8 @@ github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= -github.com/ipfs/boxo v0.8.0 h1:UdjAJmHzQHo/j3g3b1bAcAXCj/GM6iTwvSlBDvPBNBs= -github.com/ipfs/boxo v0.8.0/go.mod h1:RIsi4CnTyQ7AUsNn5gXljJYZlQrHBMnJp94p73liFiA= +github.com/ipfs/boxo v0.12.0 h1:AXHg/1ONZdRQHQLgG5JHsSC3XoE4DjCAMgK+asZvUcQ= +github.com/ipfs/boxo v0.12.0/go.mod h1:xAnfiU6PtxWCnRqu7dcXQ10bB5/kvI1kXRotuGqGBhg= github.com/ipfs/go-log v1.0.5 h1:2dOuUCB1Z7uoczMWgAyDck5JLb72zHzrMnGnCNNbvY8= github.com/ipfs/go-log v1.0.5/go.mod h1:j0b8ZoR+7+R99LD9jZ6+AJsrzkPbSXbZfGakb5JPtIo= 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+ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8= +github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/texttheater/golang-levenshtein v0.0.0-20180516184445-d188e65d659e h1:T5PdfK/M1xyrHwynxMIVMWLS7f/qHwfslZphxtGnw7s= github.com/texttheater/golang-levenshtein v0.0.0-20180516184445-d188e65d659e/go.mod h1:XDKHRm5ThF8YJjx001LtgelzsoaEcvnA7lVWz9EeX3g= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= diff --git a/http/client.go b/http/client.go index d93b5d9..14ae8e4 100644 --- a/http/client.go +++ b/http/client.go @@ -29,6 +29,7 @@ type client struct { apiPrefix string headers map[string]string fallback cmds.Executor + rawAbsPath bool } // ClientOpt is an option that can be passed to the HTTP client constructor. @@ -75,6 +76,13 @@ func ClientWithFallback(exe cmds.Executor) ClientOpt { } } +// ClientWithRawAbsPath enables the rawAbspath for [files.NewMultiFileReader]. +func ClientWithRawAbsPath(rawAbsPath bool) ClientOpt { + return func(c *client) { + c.rawAbsPath = rawAbsPath + } +} + // NewClient constructs a new HTTP-backed command executor. func NewClient(address string, opts ...ClientOpt) cmds.Executor { if !strings.HasPrefix(address, "http://") { @@ -161,10 +169,10 @@ func (c *client) toHTTPRequest(req *cmds.Request) (*http.Request, error) { // However, such is life. fileReader = files.NewMultiFileReader(files.NewMapDirectory(map[string]files.Node{ "stdin": files.NewReaderFile(bodyArgs), - }), true) + }), true, c.rawAbsPath) reader = fileReader } else if req.Files != nil { - fileReader = files.NewMultiFileReader(req.Files, true) + fileReader = files.NewMultiFileReader(req.Files, true, c.rawAbsPath) reader = fileReader } diff --git a/writer.go b/writer.go index ad31224..e214485 100644 --- a/writer.go +++ b/writer.go @@ -132,7 +132,7 @@ func (re *writerResponseEmitter) SetLength(length uint64) { return } - *re.length = length + re.length = &length } func (re *writerResponseEmitter) Close() error {