Skip to content

Commit

Permalink
dav: Correctly output mode in dirs
Browse files Browse the repository at this point in the history
  • Loading branch information
magik6k committed Oct 22, 2024
1 parent 74a6e0d commit c898055
Showing 1 changed file with 22 additions and 9 deletions.
31 changes: 22 additions & 9 deletions integrations/kuri/ribsplugin/mfsdav.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,13 +164,31 @@ func (m *mfsDavDir) Readdir(count int) ([]fs.FileInfo, error) {
}

func (m *mfsDavDir) Stat() (fs.FileInfo, error) {
return &basicFileInfos{
nd, err := m.mfd.GetNode()
if err != nil {
return nil, xerrors.Errorf("get node for dir stat: %w", err)
}

out := &basicFileInfos{
name: gopath.Base(m.path),
size: 0,
mode: 0755,
modTime: time.Unix(0, 0),
isDir: true,
}, nil
}

switch n := nd.(type) {
case *dag.ProtoNode:
d, err := ft.FSNodeFromBytes(n.Data())
if err != nil {
return nil, err
}

out.mode = d.Mode()
out.modTime = d.ModTime()
}

return out, nil
}

func (m *mfsDavDir) Write(p []byte) (n int, err error) {
Expand Down Expand Up @@ -453,16 +471,11 @@ func (m *mfsDavFs) Stat(ctx context.Context, name string) (os.FileInfo, error) {
Type: ndtype,
}, nil*/

mode := os.FileMode(0644)
if d.Type() == ft.TDirectory || d.Type() == ft.THAMTShard {
mode = os.FileMode(0755) | os.ModeDir
}

return &basicFileInfos{
name: gopath.Base(path),
size: int64(d.FileSize()), // nd.Size?
mode: mode,
modTime: time.Unix(0, 0),
mode: d.Mode(),
modTime: d.ModTime(),
isDir: d.Type() == ft.TDirectory || d.Type() == ft.THAMTShard,
}, nil
case *dag.RawNode:
Expand Down

0 comments on commit c898055

Please sign in to comment.