From 9b827be41874f781e7d985becbfdda4684e68503 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Connes?= Date: Sun, 2 Sep 2018 15:47:54 +0200 Subject: [PATCH] local: skip bad symlinks in dir listing with -L enabled - fixes #1509 --- backend/local/local.go | 9 +++++++++ 1 file changed, 9 insertions(+) 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 }