Skip to content

Commit

Permalink
Only stat version folder if current path is not itself one
Browse files Browse the repository at this point in the history
  • Loading branch information
ishank011 committed Sep 16, 2020
1 parent a8efce7 commit 2d13d19
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions pkg/eosclient/eosclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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))
}
Expand Down

0 comments on commit 2d13d19

Please sign in to comment.