Skip to content

Commit

Permalink
fix: skip list dirs with no permissions
Browse files Browse the repository at this point in the history
  • Loading branch information
zhijian-pro committed Oct 26, 2023
1 parent 606afbd commit aee3deb
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pkg/object/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,10 @@ func (d *filestore) ListAll(prefix, marker string) (<-chan Object, error) {
}

if err != nil {
if os.IsPermission(err) {
logger.Warnf("skip %s: %s", path, err)
return nil
}
if os.IsNotExist(err) {
logger.Warnf("skip not exist file or directory: %s", path)
return nil
Expand Down
4 changes: 4 additions & 0 deletions pkg/object/hdfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,10 @@ func (h *hdfsclient) ListAll(prefix, marker string) (<-chan Object, error) {
go func() {
_ = h.walk(root, func(path string, info os.FileInfo, err error) error {
if err != nil {
if os.IsPermission(err) {
logger.Warnf("skip %s: %s", path, err)
return filepath.SkipDir
}
if err == io.EOF {
err = nil // ignore
} else {
Expand Down
4 changes: 4 additions & 0 deletions pkg/object/webdav.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,10 @@ func (w *webdav) ListAll(prefix, marker string) (<-chan Object, error) {
defer close(listed)
_ = w.Walk(root, func(path string, info fs.FileInfo, err error) error {
if err != nil {
if gowebdav.IsErrCode(err, http.StatusForbidden) {
logger.Warnf("skip %s: %s", path, err)
return nil
}
if gowebdav.IsErrNotFound(err) {
logger.Warnf("skip not exist file or directory: %s", path)
return nil
Expand Down

0 comments on commit aee3deb

Please sign in to comment.