Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions backend/infra/contract/storage/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,15 @@ package storage

import (
"context"
"errors"
"io"
"time"
)

var (
ErrObjectNotFound = errors.New("object not found")
)

//go:generate mockgen -destination ../../../internal/mock/infra/contract/storage/storage_mock.go -package mock -source storage.go Factory
type Storage interface {
// PutObject puts the object with the specified key.
Expand Down
2 changes: 1 addition & 1 deletion backend/infra/impl/storage/minio/minio.go
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ func (m *minioClient) HeadObject(ctx context.Context, objectKey string, opts ...
stat, err := m.client.StatObject(ctx, m.bucketName, objectKey, minio.StatObjectOptions{})
if err != nil {
if minio.ToErrorResponse(err).Code == "NoSuchKey" {
return nil, nil
return nil, storage.ErrObjectNotFound
}

return nil, fmt.Errorf("HeadObject failed for key %s: %w", objectKey, err)
Expand Down
2 changes: 1 addition & 1 deletion backend/infra/impl/storage/s3/s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ func (t *s3Client) HeadObject(ctx context.Context, objectKey string, opts ...sto
if err != nil {
var nsk *types.NotFound
if errors.As(err, &nsk) {
return nil, nil
return nil, storage.ErrObjectNotFound
}
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion backend/infra/impl/storage/tos/tos.go
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ func (t *tosClient) HeadObject(ctx context.Context, objectKey string, opts ...st
if err != nil {
if serverErr, ok := err.(*tos.TosServerError); ok {
if serverErr.StatusCode == http.StatusNotFound {
return nil, nil
return nil, storage.ErrObjectNotFound
}
}
return nil, err
Expand Down
Loading