Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix listing directory for a read-only shares for EOS storage driver #3786

Merged
merged 2 commits into from
Apr 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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