Skip to content

Commit

Permalink
Populate the FileInfo.XS field with the file checksum (#1868)
Browse files Browse the repository at this point in the history
  • Loading branch information
ffurano authored Jul 9, 2021
1 parent 57e0474 commit 729be83
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
3 changes: 3 additions & 0 deletions changelog/unreleased/eosgrpc.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Bugfix: Minor fixes to the grpc/http plugin: checksum, url escaping

https://github.com/cs3org/reva/pull/1868
11 changes: 10 additions & 1 deletion pkg/eosclient/eosgrpc/eos_http/eoshttp.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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")
Expand Down
13 changes: 11 additions & 2 deletions pkg/eosclient/eosgrpc/eosgrpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ package eosgrpc
import (
"bytes"
"context"
"encoding/hex"
"fmt"
"io"
"io/ioutil"
Expand Down Expand Up @@ -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
Expand All @@ -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
}
Expand Down

0 comments on commit 729be83

Please sign in to comment.