fix: 解决数据库性能调整导致服务重启的问题 (#2308)

Refs #2301
This commit is contained in:
ssongliu 2023-09-15 15:28:15 +08:00 committed by GitHub
parent b6055eb058
commit 9ae935d06a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 1 deletions

View File

@ -168,7 +168,7 @@ func snapCompress(snap snapHelper, rootDir string) {
_ = snapshotRepo.UpdateStatus(snap.Status.ID, map[string]interface{}{"compress": err.Error()})
return
}
size := common.LoadSizeUnit(float64(stat.Size()))
size := common.LoadSizeUnit2F(float64(stat.Size()))
global.LOG.Debugf("compress successful! size of file: %s", size)
snap.Status.Compress = constant.StatusDone
snap.Status.Size = size

View File

@ -147,6 +147,16 @@ func RemoveRepeatElement(a interface{}) (ret []interface{}) {
}
func LoadSizeUnit(value float64) string {
if value > 1048576 {
return fmt.Sprintf("%vM", value/1048576)
}
if value > 1024 {
return fmt.Sprintf("%vK", value/1024)
}
return fmt.Sprintf("%v", value)
}
func LoadSizeUnit2F(value float64) string {
if value > 1073741824 {
return fmt.Sprintf("%.2fG", value/1073741824)
}