From acd55a8f65b0469758bf714461706ec2d62ffffe Mon Sep 17 00:00:00 2001 From: Iakov Davydov Date: Tue, 16 Jan 2018 21:00:16 +0100 Subject: [PATCH] local, fs: --exclude-if-present ignores directories which it doesn't have permission for - fixes #1959 --- backend/local/local.go | 3 +++ fs/fs.go | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/backend/local/local.go b/backend/local/local.go index d509ce732..8480d3ede 100644 --- a/backend/local/local.go +++ b/backend/local/local.go @@ -178,6 +178,9 @@ func (f *Fs) newObjectWithInfo(remote, dstPath string, info os.FileInfo) (fs.Obj if os.IsNotExist(err) { return nil, fs.ErrorObjectNotFound } + if os.IsPermission(err) { + return nil, fs.ErrorPermissionDenied + } return nil, err } } diff --git a/fs/fs.go b/fs/fs.go index df9ec7d38..b743ffb94 100644 --- a/fs/fs.go +++ b/fs/fs.go @@ -53,6 +53,7 @@ var ( ErrorCantMoveOverlapping = errors.New("can't move files on overlapping remotes") ErrorDirectoryNotEmpty = errors.New("directory not empty") ErrorImmutableModified = errors.New("immutable file modified") + ErrorPermissionDenied = errors.New("permission denied") ) // RegInfo provides information about a filesystem @@ -772,7 +773,7 @@ func CheckClose(c io.Closer, err *error) { func FileExists(fs Fs, remote string) (bool, error) { _, err := fs.NewObject(remote) if err != nil { - if err == ErrorObjectNotFound || err == ErrorNotAFile { + if err == ErrorObjectNotFound || err == ErrorNotAFile || err == ErrorPermissionDenied { return false, nil } return false, err