Skip to content

Commit

Permalink
adding a check for the key before delete for the minio client to matc…
Browse files Browse the repository at this point in the history
…h the gcs client behavior
  • Loading branch information
rayjanoka committed May 5, 2023
1 parent 256ed4c commit 76e2a22
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion client/minio.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 76e2a22

Please sign in to comment.