From ea66ae0811e4248a4beab801cd6afbb047519450 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Fri, 16 Jun 2017 10:54:46 +0200 Subject: [PATCH] s3: Fix IsNotExist() --- src/restic/backend/s3/s3.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/restic/backend/s3/s3.go b/src/restic/backend/s3/s3.go index 2fb88d2a6..6271910f5 100644 --- a/src/restic/backend/s3/s3.go +++ b/src/restic/backend/s3/s3.go @@ -84,7 +84,15 @@ func Open(cfg Config) (restic.Backend, error) { // IsNotExist returns true if the error is caused by a not existing file. func (be *Backend) IsNotExist(err error) bool { debug.Log("IsNotExist(%T, %#v)", err, err) - return os.IsNotExist(err) + if os.IsNotExist(errors.Cause(err)) { + return true + } + + if e, ok := errors.Cause(err).(minio.ErrorResponse); ok && e.Code == "NoSuchKey" { + return true + } + + return false } // Join combines path components with slashes.