diff --git a/changelog/unreleased/eosgrpc.md b/changelog/unreleased/eosgrpc.md new file mode 100644 index 0000000000..e598a5717c --- /dev/null +++ b/changelog/unreleased/eosgrpc.md @@ -0,0 +1,3 @@ +Bugfix: Minor fixes to the grpc/http plugin: checksum, url escaping + +https://github.com/cs3org/reva/pull/1868 diff --git a/pkg/eosclient/eosgrpc/eos_http/eoshttp.go b/pkg/eosclient/eosgrpc/eos_http/eoshttp.go index 0ffa07a91c..6b1340e572 100644 --- a/pkg/eosclient/eosgrpc/eos_http/eoshttp.go +++ b/pkg/eosclient/eosgrpc/eos_http/eoshttp.go @@ -239,7 +239,7 @@ func (c *Client) buildFullURL(urlpath, uid, gid string) (string, error) { return "", err } - u, err = u.Parse(urlpath) + u, err = u.Parse(url.PathEscape(urlpath)) if err != nil { return "", err } @@ -426,6 +426,15 @@ func (c *Client) PUTFile(ctx context.Context, httptransport *http.Transport, rem log.Debug().Str("func", "PUTFile").Int64("Content-Length", length).Msg("setting header") req.Header.Set("Content-Length", strconv.FormatInt(length, 10)) + } + if err != nil { + log.Error().Str("func", "PUTFile").Str("url", loc.String()).Str("err", err.Error()).Msg("can't create redirected request") + return err + } + if length >= 0 { + log.Debug().Str("func", "PUTFile").Int64("Content-Length", length).Msg("setting header") + req.Header.Set("Content-Length", strconv.FormatInt(length, 10)) + } log.Debug().Str("func", "PUTFile").Str("location", loc.String()).Msg("redirection") diff --git a/pkg/eosclient/eosgrpc/eosgrpc.go b/pkg/eosclient/eosgrpc/eosgrpc.go index e23a300026..ea4db75db3 100644 --- a/pkg/eosclient/eosgrpc/eosgrpc.go +++ b/pkg/eosclient/eosgrpc/eosgrpc.go @@ -21,6 +21,7 @@ package eosgrpc import ( "bytes" "context" + "encoding/hex" "fmt" "io" "io/ioutil" @@ -1490,6 +1491,14 @@ func (c *Client) grpcMDResponseToFileInfo(st *erpc.MDResponse, namepfx string) ( fi.Size = st.Fmd.Size + xs := &eosclient.Checksum{ + XSSum: hex.EncodeToString(st.Fmd.Checksum.Value), + XSType: st.Fmd.Checksum.Type, + } + fi.XS = xs + + log.Debug().Str("stat info - path", fi.File).Uint64("inode", fi.Inode).Uint64("uid", fi.UID).Uint64("gid", fi.GID).Str("etag", fi.ETag).Str("checksum", fi.XS.XSType+":"+fi.XS.XSSum).Msg("grpc response") + } else { fi.Inode = st.Cmd.Id fi.UID = st.Cmd.Uid @@ -1513,9 +1522,9 @@ func (c *Client) grpcMDResponseToFileInfo(st *erpc.MDResponse, namepfx string) ( } fi.Size = 0 - } - log.Debug().Str("stat info - path", fi.File).Uint64("inode:", fi.Inode).Uint64("uid:", fi.UID).Uint64("gid:", fi.GID).Str("etag:", fi.ETag).Msg("grpc response") + log.Debug().Str("stat info - path", fi.File).Uint64("inode", fi.Inode).Uint64("uid", fi.UID).Uint64("gid", fi.GID).Str("etag", fi.ETag).Msg("grpc response") + } return fi, nil }