"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files
Go azure-blobazure-blob-storageazure-filesbackblaze-b2cloud-storagedropboxencryptionftpfuse-filesystemgogolanggoogle-cloud-storagegoogle-driveonedriveopenstack-swiftrclones3sftpsyncwebdav
sftp: don't stat directories before listing them
Nick Craig-Woode6e6069ecfee
diff --git a/backend/sftp/sftp.go b/backend/sftp/sftp.goindex 6127a2333..f4a21b3c7 100644--- a/backend/sftp/sftp.go+++ b/backend/sftp/sftp.go@@ -1169,13 +1169,6 @@ func (f *Fs) dirExists(ctx context.Context, dir string) (bool, error) {// found.func (f *Fs) List(ctx context.Context, dir string) (entries fs.DirEntries, err error) {root := path.Join(f.absRoot, dir)- ok, err := f.dirExists(ctx, root)- if err != nil {- return nil, fmt.Errorf("List failed: %w", err)- }- if !ok {- return nil, fs.ErrorDirNotFound- }sftpDir := rootif sftpDir == "" {sftpDir = "."@@ -1187,6 +1180,9 @@ func (f *Fs) List(ctx context.Context, dir string) (entries fs.DirEntries, err einfos, err := c.sftpClient.ReadDir(sftpDir)f.putSftpConnection(&c, err)if err != nil {+ if errors.Is(err, os.ErrNotExist) {+ return nil, fs.ErrorDirNotFound+ }return nil, fmt.Errorf("error listing %q: %w", dir, err)}for _, info := range infos {