diff --git a/changelog/unreleased/eosclient-fxid.md b/changelog/unreleased/eosclient-fxid.md new file mode 100644 index 0000000000..fb4b1f5eb0 --- /dev/null +++ b/changelog/unreleased/eosclient-fxid.md @@ -0,0 +1,6 @@ +Enhancement: get file info using fxids from EOS + +This PR supports getting file information from EOS +using the fxid value. + +https://github.com/cs3org/reva/pull/1079 diff --git a/pkg/eosclient/eosclient.go b/pkg/eosclient/eosclient.go index 43cbf6c04a..2ea4891ef5 100644 --- a/pkg/eosclient/eosclient.go +++ b/pkg/eosclient/eosclient.go @@ -404,6 +404,16 @@ func (c *Client) GetFileInfoByInode(ctx context.Context, uid, gid string, inode return c.parseFileInfo(stdout) } +// GetFileInfoByFXID returns the FileInfo by the given file id in hexadecimal +func (c *Client) GetFileInfoByFXID(ctx context.Context, uid, gid string, fxid string) (*FileInfo, error) { + cmd := exec.CommandContext(ctx, c.opt.EosBinary, "-r", uid, gid, "file", "info", fmt.Sprintf("fxid:%s", fxid), "-m") + stdout, _, err := c.executeEOS(ctx, cmd) + if err != nil { + return nil, err + } + return c.parseFileInfo(stdout) +} + // SetAttr sets an extended attributes on a path. func (c *Client) SetAttr(ctx context.Context, uid, gid string, attr *Attribute, recursive bool, path string) error { if !attr.isValid() {