Skip to content

Commit

Permalink
Fix listing directory for a read-only shares for EOS storage driver (c…
Browse files Browse the repository at this point in the history
  • Loading branch information
gmgigi96 committed Jun 5, 2023
1 parent a79d86b commit fe7eeb4
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
9 changes: 9 additions & 0 deletions changelog/unreleased/fix-create-version-folder-on-list-eos.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Bugfix: Fix listing directory for a read-only shares for EOS storage driver

In a read-only share, while listing a folder, for resources
not having a version folder, the returned resource id was wrongly
the one of the original file, instead of the version folder.
This behavior has been fixed, where the version folder is always
created on behalf of the resource owner.

https://github.com/cs3org/reva/pull/3786
17 changes: 16 additions & 1 deletion pkg/eosclient/eosbinary/eosbinary.go
Original file line number Diff line number Diff line change
Expand Up @@ -947,12 +947,16 @@ func getMap(partsBySpace []string) map[string]string {
}

func (c *Client) parseFind(ctx context.Context, auth eosclient.Authorization, dirPath, raw string) ([]*eosclient.FileInfo, error) {
log := appctx.GetLogger(ctx)

finfos := []*eosclient.FileInfo{}
versionFolders := map[string]*eosclient.FileInfo{}
rawLines := strings.FieldsFunc(raw, func(c rune) bool {
return c == '\n'
})

var ownerAuth *eosclient.Authorization

var parent *eosclient.FileInfo
for _, rl := range rawLines {
if rl == "" {
Expand All @@ -976,6 +980,15 @@ func (c *Client) parseFind(ctx context.Context, auth eosclient.Authorization, di
versionFolders[fi.File] = fi
}

if ownerAuth == nil {
ownerAuth = &eosclient.Authorization{
Role: eosclient.Role{
UID: strconv.FormatUint(fi.UID, 10),
GID: strconv.FormatUint(fi.GID, 10),
},
}
}

finfos = append(finfos, fi)
}

Expand All @@ -993,9 +1006,11 @@ func (c *Client) parseFind(ctx context.Context, auth eosclient.Authorization, di
for k, v := range vf.Attrs {
fi.Attrs[k] = v
}
} else if err := c.CreateDir(ctx, auth, versionFolderPath); err == nil { // Create the version folder if it doesn't exist
} else if err := c.CreateDir(ctx, *ownerAuth, versionFolderPath); err == nil { // Create the version folder if it doesn't exist
if md, err := c.getRawFileInfoByPath(ctx, auth, versionFolderPath); err == nil {
fi.Inode = md.Inode
} else {
log.Error().Err(err).Interface("auth", ownerAuth).Str("path", versionFolderPath).Msg("got error creating version folder")
}
}
}
Expand Down

0 comments on commit fe7eeb4

Please sign in to comment.