Skip to content

Commit

Permalink
sync: fix nfs path and list (#4147)
Browse files Browse the repository at this point in the history
close #4140

---------

Signed-off-by: xixi <[email protected]>
  • Loading branch information
Hexilee authored Nov 9, 2023
1 parent cea8330 commit e9ca79e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
2 changes: 1 addition & 1 deletion cmd/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ func createSyncStorage(uri string, conf *sync.Config) (object.ObjectStorage, err
}
}
switch name {
case "file":
case "file", "nfs":
case "minio":
if strings.Count(u.Path, "/") > 1 {
// skip bucket name
Expand Down
25 changes: 14 additions & 11 deletions pkg/object/nfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,8 @@ func (n *nfsStore) String() string {
}

func (n *nfsStore) path(key string) string {
root := strings.TrimLeft(n.root, "/")
if strings.HasPrefix(key, root) {
return key[len(root):]
if key == "" {
return "./"
}
return key
}
Expand Down Expand Up @@ -236,9 +235,9 @@ func (n *nfsStore) readDirSorted(dirname string, followLink bool) ([]*nfsEntry,
if fi.IsDir() {
name = e.Name() + dirSuffix
}
nfsEntries[i] = &nfsEntry{e, name, fi, true}
nfsEntries[i] = &nfsEntry{e, name, fi, false}
} else {
nfsEntries[i] = &nfsEntry{e, e.Name(), nil, false}
nfsEntries[i] = &nfsEntry{e, e.Name(), nil, e.Attr.Attr.Type == nfs.NF3Lnk}
}
}
sort.Slice(nfsEntries, func(i, j int) bool { return nfsEntries[i].Name() < nfsEntries[j].Name() })
Expand Down Expand Up @@ -373,14 +372,18 @@ func (n *nfsStore) ListAll(prefix, marker string, followLink bool) (<-chan Objec
return nil, notSupported
}

func (n *nfsStore) findOwnerGroup(attr *nfs.Fattr) (string, string) {
return utils.UserName(int(attr.UID)), utils.GroupName(int(attr.GID))
}

func (n *nfsStore) getOwnerGroup(info os.FileInfo) (string, string) {
var owner, group string
switch st := info.Sys().(type) {
case *nfs.Fattr:
owner = utils.UserName(int(st.UID))
group = utils.GroupName(int(st.GID))
if st, match := info.(*nfs.Fattr); match {
return n.findOwnerGroup(st)
}
if st, match := info.Sys().(*nfs.Fattr); match {
return n.findOwnerGroup(st)
}
return owner, group
return "", ""
}

func newNFSStore(addr, username, pass, token string) (ObjectStorage, error) {
Expand Down

0 comments on commit e9ca79e

Please sign in to comment.