From 4a701725f4c5f303f4725255eca3fc2ca447e818 Mon Sep 17 00:00:00 2001 From: Gianmaria Del Monte Date: Tue, 25 Oct 2022 15:11:58 +0200 Subject: [PATCH] fix eos grpc parsing --- pkg/eosclient/eosgrpc/eosgrpc.go | 46 +++++++++++++++----------------- 1 file changed, 22 insertions(+), 24 deletions(-) diff --git a/pkg/eosclient/eosgrpc/eosgrpc.go b/pkg/eosclient/eosgrpc/eosgrpc.go index 1a29d78ef0d..7acb8307a91 100644 --- a/pkg/eosclient/eosgrpc/eosgrpc.go +++ b/pkg/eosclient/eosgrpc/eosgrpc.go @@ -1570,10 +1570,29 @@ func (c *Client) grpcMDResponseToFileInfo(st *erpc.MDResponse, namepfx string) ( } fi := new(eosclient.FileInfo) - if st.Type != 0 { + if st.Type == erpc.TYPE_CONTAINER { fi.IsDir = true - } - if st.Fmd != nil { + fi.Inode = st.Cmd.Inode + fi.FID = st.Cmd.ParentId + fi.UID = st.Cmd.Uid + fi.GID = st.Cmd.Gid + fi.MTimeSec = st.Cmd.Mtime.Sec + fi.ETag = st.Cmd.Etag + if namepfx == "" { + fi.File = string(st.Cmd.Name) + } else { + fi.File = namepfx + "/" + string(st.Cmd.Name) + } + + fi.Attrs = make(map[string]string) + for k, v := range st.Cmd.Xattrs { + fi.Attrs[k] = string(v) + } + + fi.Size = uint64(st.Cmd.TreeSize) + + 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") + } else { fi.Inode = st.Fmd.Inode fi.FID = st.Fmd.ContId fi.UID = st.Fmd.Uid @@ -1601,27 +1620,6 @@ func (c *Client) grpcMDResponseToFileInfo(st *erpc.MDResponse, namepfx string) ( 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.Inode - fi.FID = st.Fmd.ContId - fi.UID = st.Cmd.Uid - fi.GID = st.Cmd.Gid - fi.MTimeSec = st.Cmd.Mtime.Sec - fi.ETag = st.Cmd.Etag - if namepfx == "" { - fi.File = string(st.Cmd.Name) - } else { - fi.File = namepfx + "/" + string(st.Cmd.Name) - } - - fi.Attrs = make(map[string]string) - for k, v := range st.Cmd.Xattrs { - fi.Attrs[k] = string(v) - } - - 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") } return fi, nil