From c811ca3a25d024907df9ec22fd61f8b160017332 Mon Sep 17 00:00:00 2001 From: Nicola Murino Date: Tue, 8 Dec 2020 14:43:19 +0100 Subject: [PATCH] Remove: permission denied is now os.ErrPermission fix TestClientRemoveDir test case on macOS --- client.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/client.go b/client.go index 5d825ee..cdd5669 100644 --- a/client.go +++ b/client.go @@ -655,14 +655,18 @@ func (c *Client) Join(elem ...string) string { return path.Join(elem...) } // is not empty. func (c *Client) Remove(path string) error { err := c.removeFile(path) + // some servers, *cough* osx *cough*, return EPERM, not ENODIR. + // serv-u returns ssh_FX_FILE_IS_A_DIRECTORY + // EPERM is converted to os.ErrPermission so it is not a StatusError if err, ok := err.(*StatusError); ok { switch err.Code { - // some servers, *cough* osx *cough*, return EPERM, not ENODIR. - // serv-u returns ssh_FX_FILE_IS_A_DIRECTORY - case sshFxPermissionDenied, sshFxFailure, sshFxFileIsADirectory: + case sshFxFailure, sshFxFileIsADirectory: return c.RemoveDirectory(path) } } + if os.IsPermission(err) { + return c.RemoveDirectory(path) + } return err }