From 76e2a2283d617ca5f3584ea26ce165b011a2c79d Mon Sep 17 00:00:00 2001 From: Ray <18078751+rayjanoka@users.noreply.github.com> Date: Fri, 5 May 2023 12:12:10 -0600 Subject: [PATCH] adding a check for the key before delete for the minio client to match the gcs client behavior --- client/minio.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/client/minio.go b/client/minio.go index 32aa911..307ca66 100644 --- a/client/minio.go +++ b/client/minio.go @@ -93,7 +93,13 @@ func (m *Minio) PutObject(ctx context.Context, bucket string, key string, reader } func (m *Minio) RemoveObject(ctx context.Context, bucket string, key string) error { - err := m.client.RemoveObject(ctx, bucket, key, minio.RemoveObjectOptions{}) + // removeObject doesn't return an error if the key doesn't exist so check first + _, err := m.client.StatObject(ctx, bucket, key, minio.StatObjectOptions{}) + if err != nil { + return err + } + + err = m.client.RemoveObject(ctx, bucket, key, minio.RemoveObjectOptions{}) if err != nil { return err }