Skip to content

Commit

Permalink
Fix stat file for a read only share (cs3org#3765)
Browse files Browse the repository at this point in the history
  • Loading branch information
gmgigi96 committed Jun 28, 2023
1 parent bc1b486 commit 1f4c97c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
9 changes: 9 additions & 0 deletions changelog/unreleased/fix-create-version-folder-eos.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Bugfix: Fix create version folder in EOS driver

In a read only share, a stat could fail, beacause the EOS
storage driver was not able to create the version folder
for a file in case this did not exist.
This fixes this bug impersonating the owner of the
file when creating the version folder.

https://github.com/cs3org/reva/pull/3765
10 changes: 7 additions & 3 deletions pkg/eosclient/eosbinary/eosbinary.go
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,11 @@ func (c *Client) GetFileInfoByPath(ctx context.Context, auth eosclient.Authoriza
}

if c.opt.VersionInvariant && !isVersionFolder(path) && !info.IsDir {
if inode, err := c.getVersionFolderInode(ctx, auth, path); err == nil {
ownerAuth := eosclient.Authorization{Role: eosclient.Role{
UID: strconv.FormatUint(info.UID, 10),
GID: strconv.FormatUint(info.GID, 10),
}}
if inode, err := c.getVersionFolderInode(ctx, auth, ownerAuth, path); err == nil {
info.Inode = inode
}
}
Expand Down Expand Up @@ -837,11 +841,11 @@ func (c *Client) GenerateToken(ctx context.Context, auth eosclient.Authorization
return strings.TrimSpace(stdout), err
}

func (c *Client) getVersionFolderInode(ctx context.Context, auth eosclient.Authorization, p string) (uint64, error) {
func (c *Client) getVersionFolderInode(ctx context.Context, auth, ownerAuth eosclient.Authorization, p string) (uint64, error) {
versionFolder := getVersionFolder(p)
md, err := c.getRawFileInfoByPath(ctx, auth, versionFolder)
if err != nil {
if err = c.CreateDir(ctx, auth, versionFolder); err != nil {
if err = c.CreateDir(ctx, ownerAuth, versionFolder); err != nil {
return 0, err
}
md, err = c.getRawFileInfoByPath(ctx, auth, versionFolder)
Expand Down

0 comments on commit 1f4c97c

Please sign in to comment.