Skip to content

Commit

Permalink
reva: review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
amalthundiyil committed May 3, 2022
1 parent b77bc1a commit d1ce109
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 12 deletions.
13 changes: 5 additions & 8 deletions cmd/reva/download.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (
"io"
"net/http"
"os"
"time"

"github.com/cheggaaa/pb"
gateway "github.com/cs3org/go-cs3apis/cs3/gateway/v1beta1"
Expand All @@ -38,7 +37,7 @@ import (
"github.com/studio-b12/gowebdav"
)

func downloadCommand() *command {
func downloadCommand(httpClient *http.Client) *command {
cmd := newCommand("download")
cmd.Description = func() string { return "download a remote file to the local filesystem" }
cmd.Usage = func() string { return "Usage: download [-flags] <remote_file> <local_file>" }
Expand Down Expand Up @@ -102,11 +101,6 @@ func downloadCommand() *command {
}

httpReq.Header.Set(datagateway.TokenTransportHeader, p.Token)
httpClient := rhttp.GetHTTPClient(
rhttp.Context(ctx),
rhttp.Insecure(insecure),
rhttp.Timeout(time.Duration(timeout*int64(time.Hour))),
)

httpRes, err := httpClient.Do(httpReq)
if err != nil {
Expand Down Expand Up @@ -142,7 +136,10 @@ func downloadCommand() *command {
return cmd
}

func getDownloadProtocolInfo(protocolInfos []*gateway.FileDownloadProtocol, protocol string) (*gateway.FileDownloadProtocol, error) {
func getDownloadProtocolInfo(
protocolInfos []*gateway.FileDownloadProtocol,
protocol string,
) (*gateway.FileDownloadProtocol, error) {
for _, p := range protocolInfos {
if p.Protocol == protocol {
return p, nil
Expand Down
23 changes: 19 additions & 4 deletions cmd/reva/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ var (
lsCommand(),
statCommand(),
uploadCommand(),
downloadCommand(),
downloadCommand(client),
rmCommand(),
moveCommand(),
mkdirCommand(),
Expand Down Expand Up @@ -97,8 +97,18 @@ var (
func init() {
flag.StringVar(&host, "host", "", "address of the GRPC gateway host")
flag.BoolVar(&insecure, "insecure", false, "disables grpc transport security")
flag.BoolVar(&insecuredatagateway, "insecure-data-gateway", false, "disables grpc transport security for data gateway service")
flag.BoolVar(&skipverify, "skip-verify", false, "whether to skip verifying the server's certificate chain and host name")
flag.BoolVar(
&insecuredatagateway,
"insecure-data-gateway",
false,
"disables grpc transport security for data gateway service",
)
flag.BoolVar(
&skipverify,
"skip-verify",
false,
"whether to skip verifying the server's certificate chain and host name",
)
flag.BoolVar(&disableargprompt, "disable-arg-prompt", false, "whether to disable prompts for command arguments")
flag.Int64Var(&timeout, "timeout", -1, "the timeout in seconds for executing the commands, -1 means no timeout")
flag.Parse()
Expand Down Expand Up @@ -152,6 +162,11 @@ func generateMainUsage() {

helpCommandOutput = "Command line interface to REVA:\n"
for _, cmd := range commands {
helpCommandOutput += fmt.Sprintf("%s%s%s\n", cmd.Name, strings.Repeat(" ", 4+(n-len(cmd.Name))), cmd.Description())
helpCommandOutput += fmt.Sprintf(
"%s%s%s\n",
cmd.Name,
strings.Repeat(" ", 4+(n-len(cmd.Name))),
cmd.Description(),
)
}
}

0 comments on commit d1ce109

Please sign in to comment.