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
This commit is contained in:
Nick Craig-Wood 2023-05-10 15:06:13 +01:00
parent e6e6069ecf
commit 2cd85813b4

View File

@ -1066,7 +1066,7 @@ func NewFsWithConnection(ctx context.Context, f *Fs, name string, root string, m
} }
} }
f.putSftpConnection(&c, err) f.putSftpConnection(&c, err)
if root != "" { if root != "" && !strings.HasSuffix(root, "/") {
// Check to see if the root is actually an existing file, // Check to see if the root is actually an existing file,
// and if so change the filesystem root to its parent directory. // and if so change the filesystem root to its parent directory.
oldAbsRoot := f.absRoot oldAbsRoot := f.absRoot