From 4032af0b787858c2e7458f4755a9cbe0431e8d46 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Sat, 13 Feb 2016 19:11:41 +0100 Subject: [PATCH] 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. --- backend/sftp/sftp.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/backend/sftp/sftp.go b/backend/sftp/sftp.go index fb10c3854..a4b3ac73a 100644 --- a/backend/sftp/sftp.go +++ b/backend/sftp/sftp.go @@ -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 }