"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: check directory is empty before issuing rmdir
Nick Craig-Wood0eba88bbfe44
diff --git a/backend/sftp/sftp.go b/backend/sftp/sftp.goindex cfa6d4007..e37d83f9c 100644--- a/backend/sftp/sftp.go+++ b/backend/sftp/sftp.go@@ -594,6 +594,16 @@ func (f *Fs) Mkdir(dir string) error {// Rmdir removes the root directory of the Fs objectfunc (f *Fs) Rmdir(dir string) error {+ // Check to see if directory is empty as some servers will+ // delete recursively with RemoveDirectory+ entries, err := f.List(dir)+ if err != nil {+ return errors.Wrap(err, "Rmdir")+ }+ if len(entries) != 0 {+ return fs.ErrorDirectoryNotEmpty+ }+ // Remove the directoryroot := path.Join(f.root, dir)c, err := f.getSftpConnection()if err != nil {