Merge pull request #372 from alimy/pr-371

optimized minio removeobjects
jc/alimy v0.4.2
北野 - Michael Li 1 year ago committed by GitHub
commit f4164a6a89
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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).[#371](https://github.com/rocboss/paopao-ce/pull/371) [#372](https://github.com/rocboss/paopao-ce/pull/372)
## 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