diff --git a/pkg/eosclient/eosbinary/eosbinary.go b/pkg/eosclient/eosbinary/eosbinary.go index 94b02bdbe84..dd00f2f25a1 100644 --- a/pkg/eosclient/eosbinary/eosbinary.go +++ b/pkg/eosclient/eosbinary/eosbinary.go @@ -462,16 +462,7 @@ func (c *Client) GetFileInfoByInode(ctx context.Context, auth eosclient.Authoriz info.Inode = inode } - // We need to inherit the ACLs for the parent directory as these are not available for files - if !info.IsDir { - parentInfo, err := c.GetFileInfoByPath(ctx, auth, path.Dir(info.File)) - // Even if this call fails, at least return the current file object - if err == nil { - info.SysACL.Entries = append(info.SysACL.Entries, parentInfo.SysACL.Entries...) - } - } - - return info, nil + return c.mergeParentACLsForFiles(ctx, auth, info), nil } // GetFileInfoByFXID returns the FileInfo by the given file id in hexadecimal @@ -487,16 +478,7 @@ func (c *Client) GetFileInfoByFXID(ctx context.Context, auth eosclient.Authoriza return nil, err } - // We need to inherit the ACLs for the parent directory as these are not available for files - if !info.IsDir { - parentInfo, err := c.GetFileInfoByPath(ctx, auth, path.Dir(info.File)) - // Even if this call fails, at least return the current file object - if err == nil { - info.SysACL.Entries = append(info.SysACL.Entries, parentInfo.SysACL.Entries...) - } - } - - return info, nil + return c.mergeParentACLsForFiles(ctx, auth, info), nil } // GetFileInfoByPath returns the FilInfo at the given path @@ -517,6 +499,10 @@ func (c *Client) GetFileInfoByPath(ctx context.Context, auth eosclient.Authoriza } } + return c.mergeParentACLsForFiles(ctx, auth, info), nil +} + +func (c *Client) mergeParentACLsForFiles(ctx context.Context, auth eosclient.Authorization, info *eosclient.FileInfo) *eosclient.FileInfo { // We need to inherit the ACLs for the parent directory as these are not available for files if !info.IsDir { parentInfo, err := c.GetFileInfoByPath(ctx, auth, path.Dir(info.File)) @@ -525,8 +511,7 @@ func (c *Client) GetFileInfoByPath(ctx context.Context, auth eosclient.Authoriza info.SysACL.Entries = append(info.SysACL.Entries, parentInfo.SysACL.Entries...) } } - - return info, nil + return info } // SetAttr sets an extended attributes on a path. diff --git a/pkg/eosclient/eosgrpc/eosgrpc.go b/pkg/eosclient/eosgrpc/eosgrpc.go index 0c5e81a5446..ae9f49a7333 100644 --- a/pkg/eosclient/eosgrpc/eosgrpc.go +++ b/pkg/eosclient/eosgrpc/eosgrpc.go @@ -484,6 +484,11 @@ func (c *Client) GetFileInfoByInode(ctx context.Context, auth eosclient.Authoriz info.Inode = inode } + log.Debug().Str("func", "GetFileInfoByInode").Uint64("inode", inode).Msg("") + return c.mergeParentACLsForFiles(ctx, auth, info), nil +} + +func (c *Client) mergeParentACLsForFiles(ctx context.Context, auth eosclient.Authorization, info *eosclient.FileInfo) *eosclient.FileInfo { // We need to inherit the ACLs for the parent directory as these are not available for files if !info.IsDir { parentInfo, err := c.GetFileInfoByPath(ctx, auth, path.Dir(info.File)) @@ -492,9 +497,7 @@ func (c *Client) GetFileInfoByInode(ctx context.Context, auth eosclient.Authoriz info.SysACL.Entries = append(info.SysACL.Entries, parentInfo.SysACL.Entries...) } } - - log.Debug().Str("func", "GetFileInfoByInode").Uint64("inode", inode).Msg("") - return info, nil + return info } // SetAttr sets an extended attributes on a path. @@ -637,16 +640,7 @@ func (c *Client) GetFileInfoByPath(ctx context.Context, auth eosclient.Authoriza info.Inode = inode } - // We need to inherit the ACLs for the parent directory as these are not available for files - if !info.IsDir { - parentInfo, err := c.GetFileInfoByPath(ctx, auth, path.Dir(info.File)) - // Even if this call fails, at least return the current file object - if err == nil { - info.SysACL.Entries = append(info.SysACL.Entries, parentInfo.SysACL.Entries...) - } - } - - return info, nil + return c.mergeParentACLsForFiles(ctx, auth, info), nil } // GetFileInfoByFXID returns the FileInfo by the given file id in hexadecimal