Skip to content

Commit

Permalink
Return the inode of the version folder for files when listing in EOS
Browse files Browse the repository at this point in the history
  • Loading branch information
ishank011 committed Nov 16, 2021
1 parent 17606d3 commit 32b86c0
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
3 changes: 3 additions & 0 deletions changelog/unreleased/eos-list-file-version-inode.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Bugfix: Return the inode of the version folder for files when listing in EOS

https://github.com/cs3org/reva/pull/2279
18 changes: 16 additions & 2 deletions pkg/eosclient/eosbinary/eosbinary.go
Original file line number Diff line number Diff line change
Expand Up @@ -873,6 +873,7 @@ func getMap(partsBySpace []string) map[string]string {

func (c *Client) parseFind(dirPath, raw string) ([]*eosclient.FileInfo, error) {
finfos := []*eosclient.FileInfo{}
versionFolders := map[string]*eosclient.FileInfo{}
rawLines := strings.FieldsFunc(raw, func(c rune) bool {
return c == '\n'
})
Expand All @@ -894,13 +895,26 @@ func (c *Client) parseFind(dirPath, raw string) ([]*eosclient.FileInfo, error) {
continue
}

// If it's a version folder, store it in a map, so that for the corresponding file,
// we can return its inode instead
if isVersionFolder(fi.File) {
versionFolders[fi.File] = fi
}

finfos = append(finfos, fi)
}

for _, fi := range finfos {
// For files, inherit ACLs from the parent
if !fi.IsDir && parent != nil {
fi.SysACL.Entries = append(fi.SysACL.Entries, parent.SysACL.Entries...)
// And set the inode to that of their version folder
if !fi.IsDir {
if parent != nil {
fi.SysACL.Entries = append(fi.SysACL.Entries, parent.SysACL.Entries...)
}
versionFolderPath := getVersionFolder(fi.File)
if vf, ok := versionFolders[versionFolderPath]; ok {
fi.Inode = vf.Inode
}
}
}

Expand Down

0 comments on commit 32b86c0

Please sign in to comment.