2
2
mirror of https://github.com/octoleo/restic.git synced 2024-11-22 21:05:10 +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:
Alexander Neumann 2016-02-13 19:11:41 +01:00
parent 2bb55f017d
commit 4032af0b78

View File

@ -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
}