From a61d219bcd3ffa3ee0411e7d3759c0ef5e22e495 Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Mon, 14 Nov 2022 17:59:33 +0000 Subject: [PATCH] local: fix -L/--copy-links with filters missing directories In this commit 8d1fff9a8237c64f local: obey file filters in listing to fix errors on excluded files We introduced the concept of local backend filters. Unfortunately the filters were being applied before we had resolved the symlink to point to a directory. This meant that symlinks pointing to directories were filtered out when they shouldn't have been. This was fixed by moving the filter check until after the symlink had been resolved. See: https://forum.rclone.org/t/copy-links-not-following-symlinks-on-1-60-0/34073/7 --- backend/local/local.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/backend/local/local.go b/backend/local/local.go index 8d16ad4a8..67784f8e6 100644 --- a/backend/local/local.go +++ b/backend/local/local.go @@ -520,11 +520,6 @@ func (f *Fs) List(ctx context.Context, dir string) (entries fs.DirEntries, err e name := fi.Name() mode := fi.Mode() newRemote := f.cleanRemote(dir, name) - // Don't include non directory if not included - // we leave directory filtering to the layer above - if useFilter && !fi.IsDir() && !filter.IncludeRemote(newRemote) { - continue - } // Follow symlinks if required if f.opt.FollowSymlinks && (mode&os.ModeSymlink) != 0 { localPath := filepath.Join(fsDirPath, name) @@ -541,6 +536,11 @@ func (f *Fs) List(ctx context.Context, dir string) (entries fs.DirEntries, err e } mode = fi.Mode() } + // Don't include non directory if not included + // we leave directory filtering to the layer above + if useFilter && !fi.IsDir() && !filter.IncludeRemote(newRemote) { + continue + } if fi.IsDir() { // Ignore directories which are symlinks. These are junction points under windows which // are kind of a souped up symlink. Unix doesn't have directories which are symlinks.