From 262282c61ae9a069b0e9187a04738bb081175deb Mon Sep 17 00:00:00 2001 From: huanghaoyuanhhy Date: Mon, 1 Apr 2024 20:09:31 +0800 Subject: [PATCH] storage: ignore key not found error when deleting files Signed-off-by: huanghaoyuanhhy --- storage/minio.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/storage/minio.go b/storage/minio.go index 590340f..352aa1d 100644 --- a/storage/minio.go +++ b/storage/minio.go @@ -4,6 +4,7 @@ import ( "context" "errors" "fmt" + "strings" "github.com/minio/minio-go/v7" ) @@ -97,7 +98,10 @@ func (m *MinioClient) DeleteObjects(ctx context.Context, i DeleteObjectsInput) e job := func(ctx context.Context) error { // we can't use RemoveObjects, because gcp doesn't support batch delete if err := m.cli.RemoveObject(ctx, i.Bucket, key, minio.RemoveObjectOptions{}); err != nil { - return fmt.Errorf("storage: %s delete prefix remove key: %s %w", m.provider, key, err) + if !strings.Contains(err.Error(), "The specified key does not exist") { + // if key not exist, we can ignore it + return fmt.Errorf("storage: %s delete prefix remove key: %s %w", m.provider, key, err) + } } return nil