forked from TrueCloudLab/restic
sftp: Use os.IsNotExist() for Test()
The sftp library introduced a change so that the error returned for (among others) Lstat() can be used with os.IsNotExist() to test whether the target file does not exist.
This commit is contained in:
parent
2bb55f017d
commit
4032af0b78
1 changed files with 4 additions and 4 deletions
|
@ -360,11 +360,11 @@ func (r *SFTP) Stat(h backend.Handle) (backend.BlobInfo, error) {
|
|||
// Test returns true if a blob of the given type and name exists in the backend.
|
||||
func (r *SFTP) Test(t backend.Type, name string) (bool, error) {
|
||||
_, err := r.c.Lstat(r.filename(t, name))
|
||||
if err != nil {
|
||||
if _, ok := err.(*sftp.StatusError); ok {
|
||||
return false, nil
|
||||
}
|
||||
if os.IsNotExist(err) {
|
||||
return false, nil
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue