Skip to content

Commit

Permalink
Merge pull request #371 from cute-angelia/main
Browse files Browse the repository at this point in the history
fix minio removeobjects
  • Loading branch information
alimy authored Aug 27, 2023
2 parents c1a7597 + 7a479e2 commit 0f2e0b2
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions internal/dao/storage/minio.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,13 +134,16 @@ func (s *minioServant) DeleteObject(objectKey string) error {
func (s *minioServant) DeleteObjects(objectKeys []string) (err error) {
objectsCh := make(chan minio.ObjectInfo, len(objectKeys))

resCh := s.client.RemoveObjects(context.Background(), s.bucket, objectsCh, minio.RemoveObjectsOptions{})
for _, objectKey := range objectKeys {
objectsCh <- minio.ObjectInfo{
Key: objectKey,
go func() {
defer close(objectsCh)
for _, objectKey := range objectKeys {
objectsCh <- minio.ObjectInfo{
Key: objectKey,
}
}
}
}()

resCh := s.client.RemoveObjects(context.Background(), s.bucket, objectsCh, minio.RemoveObjectsOptions{})
// 宽松处理所有错误,只记录最后一次发生的错误
for result := range resCh {
if result.Err != nil {
Expand Down

0 comments on commit 0f2e0b2

Please sign in to comment.