optimized minio removeobjects

pull/372/head
Michael Li 1 year ago
parent 7a479e2ed4
commit a02d4d24d8
No known key found for this signature in database

@ -2,6 +2,10 @@
All notable changes to paopao-ce are documented in this file. All notable changes to paopao-ce are documented in this file.
## 0.5.0+dev ([`dev`](https://github.com/rocboss/paopao-ce/tree/dev)) ## 0.5.0+dev ([`dev`](https://github.com/rocboss/paopao-ce/tree/dev))
## 0.4.2
### Fixed
- fixed remove multi-objects no effects and occurs resource leak error when use Minio as OSS(Object Storage System).
## 0.4.1 ## 0.4.1
### Changed ### Changed
- infinite scrolling instead of pagination for Home/User/Profile page - infinite scrolling instead of pagination for Home/User/Profile page

@ -134,16 +134,15 @@ func (s *minioServant) DeleteObject(objectKey string) error {
func (s *minioServant) DeleteObjects(objectKeys []string) (err error) { func (s *minioServant) DeleteObjects(objectKeys []string) (err error) {
objectsCh := make(chan minio.ObjectInfo, len(objectKeys)) objectsCh := make(chan minio.ObjectInfo, len(objectKeys))
go func() { resCh := s.client.RemoveObjects(context.Background(), s.bucket, objectsCh, minio.RemoveObjectsOptions{})
defer close(objectsCh) for _, objectKey := range objectKeys {
for _, objectKey := range objectKeys { objectsCh <- minio.ObjectInfo{
objectsCh <- minio.ObjectInfo{ Key: objectKey,
Key: objectKey,
}
} }
}() }
// 记得一定要close否则会被卡死退出不了函数造成资源泄露
close(objectsCh)
resCh := s.client.RemoveObjects(context.Background(), s.bucket, objectsCh, minio.RemoveObjectsOptions{})
// 宽松处理所有错误,只记录最后一次发生的错误 // 宽松处理所有错误,只记录最后一次发生的错误
for result := range resCh { for result := range resCh {
if result.Err != nil { if result.Err != nil {

Loading…
Cancel
Save