Fix storage Iterate bug and Add storage doctor to delete garbage attachments (#16971)

* Fix storage Iterate bug and Add storage doctor to delete garbage attachments

* Close object when used
This commit is contained in:
Lunny Xiao 2021-09-06 22:46:20 +08:00 committed by GitHub
parent 82da380af7
commit a807031a30
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 83 additions and 3 deletions

View file

@ -151,7 +151,7 @@ type minioFileInfo struct {
}
func (m minioFileInfo) Name() string {
return m.ObjectInfo.Key
return path.Base(m.ObjectInfo.Key)
}
func (m minioFileInfo) Size() int64 {
@ -219,7 +219,7 @@ func (m *MinioStorage) IterateObjects(fn func(path string, obj Object) error) er
}
if err := func(object *minio.Object, fn func(path string, obj Object) error) error {
defer object.Close()
return fn(strings.TrimPrefix(m.basePath, mObjInfo.Key), &minioObject{object})
return fn(strings.TrimPrefix(mObjInfo.Key, m.basePath), &minioObject{object})
}(object, fn); err != nil {
return convertMinioErr(err)
}