From 7eae867ec1b341e307911d0c74c9367dd5db4c00 Mon Sep 17 00:00:00 2001 From: Marius Date: Sat, 19 Mar 2022 23:41:54 +0100 Subject: [PATCH] azurestore: Work around error being not comparable --- pkg/azurestore/azurestore.go | 8 ++++++-- pkg/handler/error.go | 2 ++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/pkg/azurestore/azurestore.go b/pkg/azurestore/azurestore.go index a63d959..d21cbf0 100644 --- a/pkg/azurestore/azurestore.go +++ b/pkg/azurestore/azurestore.go @@ -112,8 +112,12 @@ func (store AzureStore) GetUpload(ctx context.Context, id string) (handler.Uploa } offset, err := blockBlob.GetOffset(ctx) - if err != nil && err != handler.ErrNotFound { - return nil, err + if err != nil { + // Unpack the error and see if it is a handler.ErrNotFound by comparing the + // error code. If it matches, we ignore the error, otherwise we return the error. + if handlerErr, ok := err.(handler.Error); !ok || handlerErr.ErrorCode != handler.ErrNotFound.ErrorCode { + return nil, err + } } info.Offset = offset diff --git a/pkg/handler/error.go b/pkg/handler/error.go index f4a518e..670fe2c 100644 --- a/pkg/handler/error.go +++ b/pkg/handler/error.go @@ -3,6 +3,8 @@ package handler // Error represents an error with the intent to be sent in the HTTP // response to the client. Therefore, it also contains a HTTPResponse, // next to an error code and error message. +// TODO: Error is not comparable anymore because HTTPResponse +// contains a map. See if we should change this. type Error struct { ErrorCode string Message string