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 {
if os.IsNotExist(err) {
return false, nil
}
if err != nil {
return false, err
}