mirror of
https://github.com/octoleo/restic.git
synced 2024-12-23 11:28:54 +00:00
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
@ -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 New Issue
Block a user