Upgrade pkg/sftp to 1.13 and simplify SFTP.IsNotExist
This commit is contained in:
parent
c9b4fadd91
commit
187a77fb27
3 changed files with 14 additions and 19 deletions
|
@ -165,17 +165,7 @@ func (r *SFTP) ReadDir(ctx context.Context, dir string) ([]os.FileInfo, error) {
|
|||
// IsNotExist returns true if the error is caused by a not existing file.
|
||||
func (r *SFTP) IsNotExist(err error) bool {
|
||||
err = errors.Cause(err)
|
||||
|
||||
if os.IsNotExist(err) {
|
||||
return true
|
||||
}
|
||||
|
||||
statusError, ok := err.(*sftp.StatusError)
|
||||
if !ok {
|
||||
return false
|
||||
}
|
||||
|
||||
return statusError.Error() == `sftp: "No such file" (SSH_FX_NO_SUCH_FILE)`
|
||||
return errors.Is(err, os.ErrNotExist)
|
||||
}
|
||||
|
||||
func buildSSHCommand(cfg Config) (cmd string, args []string, err error) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue