From 96e14bf4564ccb7a305452c7eab40fb86f91fdeb Mon Sep 17 00:00:00 2001
From: Nick Craig-Wood <nick@craig-wood.com>
Date: Sat, 16 Oct 2021 10:32:29 +0100
Subject: [PATCH] sftp: fix initialization bug introduced by fs.ErrorIsDir
 return

3fbaa4c0b0e8076b backends: make NewObject return fs.ErrorIsDir if possible
---
 backend/sftp/sftp.go | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/backend/sftp/sftp.go b/backend/sftp/sftp.go
index af2d0abbe..7b6e2ae3b 100644
--- a/backend/sftp/sftp.go
+++ b/backend/sftp/sftp.go
@@ -784,7 +784,7 @@ func NewFsWithConnection(ctx context.Context, f *Fs, name string, root string, m
 		}
 		_, err := f.NewObject(ctx, remote)
 		if err != nil {
-			if err == fs.ErrorObjectNotFound || errors.Cause(err) == fs.ErrorNotAFile {
+			if err == fs.ErrorObjectNotFound || err == fs.ErrorIsDir {
 				// File doesn't exist so return old f
 				f.root = root
 				f.absRoot = oldAbsRoot