diff --git a/pkg/client/fs/fs.go b/pkg/client/fs/fs.go index 1bf72fdc..6848babe 100644 --- a/pkg/client/fs/fs.go +++ b/pkg/client/fs/fs.go @@ -178,7 +178,6 @@ func (f *fsClient) listInRoutine(contentCh chan client.ContentOnChannel) { } return } - switch fi.Mode().IsDir() { case true: // do not use ioutil.ReadDir(), since it tries to sort its @@ -207,20 +206,22 @@ func (f *fsClient) listInRoutine(contentCh chan client.ContentOnChannel) { return } } - content := &client.Content{ - Name: fi.Name(), - Time: fi.ModTime(), - Size: fi.Size(), - Type: fi.Mode(), - } - contentCh <- client.ContentOnChannel{ - Content: content, - Err: nil, + if fi.Mode().IsRegular() || fi.Mode().IsDir() { + content := &client.Content{ + Name: fi.Name(), + Time: fi.ModTime(), + Size: fi.Size(), + Type: fi.Mode(), + } + contentCh <- client.ContentOnChannel{ + Content: content, + Err: nil, + } } } default: content := &client.Content{ - Name: f.path, + Name: fi.Name(), Time: fi.ModTime(), Size: fi.Size(), Type: fi.Mode(), @@ -239,29 +240,35 @@ func (f *fsClient) listRecursiveInRoutine(contentCh chan client.ContentOnChannel if fp == f.path { return nil } - if err != nil { - if strings.Contains(err.Error(), "operation not permitted") || - // os.IsNotExist(err) || - os.IsPermission(err) { // skip inaccessible files - return nil - } - return iodine.New(err, nil) // abort - } if fi.Mode()&os.ModeSymlink == os.ModeSymlink { fi, err = os.Stat(fp) if err != nil { + if os.IsNotExist(err) { // ignore broken symlinks + return nil + } return iodine.New(err, nil) } } - content := &client.Content{ - Name: fp, - Time: fi.ModTime(), - Size: fi.Size(), - Type: fi.Mode(), - } - contentCh <- client.ContentOnChannel{ - Content: content, - Err: nil, + if fi.Mode().IsRegular() || fi.Mode().IsDir() { + if err != nil { + if strings.Contains(err.Error(), "operation not permitted") { + return nil + } + if os.IsPermission(err) { + return nil + } + return iodine.New(err, nil) // abort + } + content := &client.Content{ + Name: fp, + Time: fi.ModTime(), + Size: fi.Size(), + Type: fi.Mode(), + } + contentCh <- client.ContentOnChannel{ + Content: content, + Err: nil, + } } return nil }