From 2d13d19101fecd50f4124a1e903a75d844fff926 Mon Sep 17 00:00:00 2001 From: Ishank Arora Date: Wed, 16 Sep 2020 11:56:25 +0200 Subject: [PATCH] Only stat version folder if current path is not itself one --- pkg/eosclient/eosclient.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pkg/eosclient/eosclient.go b/pkg/eosclient/eosclient.go index a296addca1d..e10bc319d46 100644 --- a/pkg/eosclient/eosclient.go +++ b/pkg/eosclient/eosclient.go @@ -410,7 +410,7 @@ func (c *Client) GetFileInfoByInode(ctx context.Context, uid, gid string, inode return nil, err } - if c.opt.VersionInvariant { + if c.opt.VersionInvariant && isVersionFolder(info.File) { info, err = c.getFileInfoFromVersion(ctx, uid, gid, info.File) if err != nil { return nil, err @@ -475,7 +475,7 @@ func (c *Client) GetFileInfoByPath(ctx context.Context, uid, gid, path string) ( return nil, err } - if c.opt.VersionInvariant { + if c.opt.VersionInvariant && !isVersionFolder(path) { inode, err := c.getVersionFolderInode(ctx, uid, gid, path) if err != nil { return nil, err @@ -662,6 +662,10 @@ func (c *Client) getFileInfoFromVersion(ctx context.Context, uid, gid, p string) return md, nil } +func isVersionFolder(p string) bool { + return strings.HasPrefix(path.Base(p), versionPrefix) +} + func getVersionFolder(p string) string { return path.Join(path.Dir(p), versionPrefix+path.Base(p)) }