local, fs: --exclude-if-present ignores directories which it doesn't have permission for - fixes #1959

This commit is contained in:
Iakov Davydov 2018-01-16 21:00:16 +01:00 committed by Nick Craig-Wood
parent ad76dd0adc
commit acd55a8f65
2 changed files with 5 additions and 1 deletions

View File

@ -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
}
}

View File

@ -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