From 2cd85813b41a96c9363515ac075c2bf107a26ab6 Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Wed, 10 May 2023 15:06:13 +0100 Subject: [PATCH] sftp: don't check remote points to a file if it ends with / This avoids calling stat on the root directory which saves a call and some servers don't like. See: https://forum.rclone.org/t/stat-failed-error-on-sftp/38045 --- 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 f4a21b3c7..aaec27b60 100644 --- a/backend/sftp/sftp.go +++ b/backend/sftp/sftp.go @@ -1066,7 +1066,7 @@ func NewFsWithConnection(ctx context.Context, f *Fs, name string, root string, m } } f.putSftpConnection(&c, err) - if root != "" { + if root != "" && !strings.HasSuffix(root, "/") { // Check to see if the root is actually an existing file, // and if so change the filesystem root to its parent directory. oldAbsRoot := f.absRoot