Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix!: client with raw abs path option #243

Merged
merged 2 commits into from
Aug 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand All @@ -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=
Expand Down
12 changes: 10 additions & 2 deletions http/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
apiPrefix string
headers map[string]string
fallback cmds.Executor
rawAbsPath bool
}

// ClientOpt is an option that can be passed to the HTTP client constructor.
Expand Down Expand Up @@ -75,6 +76,13 @@
}
}

// ClientWithRawAbsPath enables the rawAbspath for [files.NewMultiFileReader].
func ClientWithRawAbsPath(rawAbsPath bool) ClientOpt {
return func(c *client) {
c.rawAbsPath = rawAbsPath
}

Check warning on line 83 in http/client.go

View check run for this annotation

Codecov / codecov/patch

http/client.go#L80-L83

Added lines #L80 - L83 were not covered by tests
}

// NewClient constructs a new HTTP-backed command executor.
func NewClient(address string, opts ...ClientOpt) cmds.Executor {
if !strings.HasPrefix(address, "http://") {
Expand Down Expand Up @@ -161,10 +169,10 @@
// However, such is life.
fileReader = files.NewMultiFileReader(files.NewMapDirectory(map[string]files.Node{
"stdin": files.NewReaderFile(bodyArgs),
}), true)
}), true, c.rawAbsPath)

Check warning on line 172 in http/client.go

View check run for this annotation

Codecov / codecov/patch

http/client.go#L172

Added line #L172 was not covered by tests
reader = fileReader
} else if req.Files != nil {
fileReader = files.NewMultiFileReader(req.Files, true)
fileReader = files.NewMultiFileReader(req.Files, true, c.rawAbsPath)
reader = fileReader
}

Expand Down
2 changes: 1 addition & 1 deletion writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@
return
}

*re.length = length
re.length = &length

Check warning on line 135 in writer.go

View check run for this annotation

Codecov / codecov/patch

writer.go#L135

Added line #L135 was not covered by tests
hacdias marked this conversation as resolved.
Show resolved Hide resolved
}

func (re *writerResponseEmitter) Close() error {
Expand Down