Skip to content

"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files

local: skip bad symlinks in dir listing with -L enabled - fixes #1509

Cédric Connes9b827be41874
diff --git a/backend/local/local.go b/backend/local/local.go
index 26ae8ede1..71b52b723 100644
--- a/backend/local/local.go
+++ b/backend/local/local.go
@@ -16,8 +16,10 @@ import (
"unicode/utf8"
"github.com/ncw/rclone/fs"
+ "github.com/ncw/rclone/fs/accounting"
"github.com/ncw/rclone/fs/config/configmap"
"github.com/ncw/rclone/fs/config/configstruct"
+ "github.com/ncw/rclone/fs/fserrors"
"github.com/ncw/rclone/fs/hash"
"github.com/ncw/rclone/lib/readers"
"github.com/pkg/errors"
@@ -280,6 +282,13 @@ func (f *Fs) List(dir string) (entries fs.DirEntries, err error) {
// Follow symlinks if required
if f.opt.FollowSymlinks && (mode&os.ModeSymlink) != 0 {
fi, err = os.Stat(newPath)
+ if os.IsNotExist(err) {
+ // Skip bad symlinks
+ err = fserrors.NoRetryError(errors.Wrap(err, "symlink"))
+ fs.Errorf(newRemote, "Listing error: %v", err)
+ accounting.Stats.Error(err)
+ continue
+ }
if err != nil {
return nil, err
}