From 876bf8aa4f911682e6b9e0d70423b171ecb15aad Mon Sep 17 00:00:00 2001
From: Nicola Murino <nicola.murino@gmail.com>
Date: Wed, 16 Feb 2022 16:46:28 +0100
Subject: [PATCH] sftpfs: improve remove

we know if the client asks to remove a file or directory so let's
use the appropriate command without letting the sftp library guess
the appropriate behavior

Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
---
 vfs/sftpfs.go | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/vfs/sftpfs.go b/vfs/sftpfs.go
index 7ce307ce..9c3800a5 100644
--- a/vfs/sftpfs.go
+++ b/vfs/sftpfs.go
@@ -335,6 +335,9 @@ func (fs *SFTPFs) Remove(name string, isDir bool) error {
 	if err := fs.checkConnection(); err != nil {
 		return err
 	}
+	if isDir {
+		return fs.sftpClient.RemoveDirectory(name)
+	}
 	return fs.sftpClient.Remove(name)
 }