Skip to content

Commit

Permalink
Create version folder if it didn't exist while listing
Browse files Browse the repository at this point in the history
  • Loading branch information
ishank011 committed Nov 16, 2021
1 parent 32b86c0 commit 7ee0d69
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions pkg/eosclient/eosbinary/eosbinary.go
Original file line number Diff line number Diff line change
Expand Up @@ -652,7 +652,7 @@ func (c *Client) List(ctx context.Context, auth eosclient.Authorization, path st
if err != nil {
return nil, errors.Wrapf(err, "eosclient: error listing fn=%s", path)
}
return c.parseFind(path, stdout)
return c.parseFind(ctx, auth, path, stdout)
}

// Read reads a file from the mgm
Expand Down Expand Up @@ -871,7 +871,7 @@ func getMap(partsBySpace []string) map[string]string {
return kv
}

func (c *Client) parseFind(dirPath, raw string) ([]*eosclient.FileInfo, error) {
func (c *Client) parseFind(ctx context.Context, auth eosclient.Authorization, dirPath, raw string) ([]*eosclient.FileInfo, error) {
finfos := []*eosclient.FileInfo{}
versionFolders := map[string]*eosclient.FileInfo{}
rawLines := strings.FieldsFunc(raw, func(c rune) bool {
Expand Down Expand Up @@ -914,6 +914,10 @@ func (c *Client) parseFind(dirPath, raw string) ([]*eosclient.FileInfo, error) {
versionFolderPath := getVersionFolder(fi.File)
if vf, ok := versionFolders[versionFolderPath]; ok {
fi.Inode = vf.Inode
} else if err := c.CreateDir(ctx, auth, versionFolderPath); err == nil {
if md, err := c.GetFileInfoByPath(ctx, auth, versionFolderPath); err == nil {
fi.Inode = md.Inode
}
}
}
}
Expand Down

0 comments on commit 7ee0d69

Please sign in to comment.