mirror of https://github.com/pkg/sftp.git
Remove: permission denied is now os.ErrPermission
fix TestClientRemoveDir test case on macOS
This commit is contained in:
parent
f5fd2fb058
commit
c811ca3a25
10
client.go
10
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
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue