mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-01-19 08:19:15 +08:00
parent
b6055eb058
commit
9ae935d06a
@ -168,7 +168,7 @@ func snapCompress(snap snapHelper, rootDir string) {
|
|||||||
_ = snapshotRepo.UpdateStatus(snap.Status.ID, map[string]interface{}{"compress": err.Error()})
|
_ = snapshotRepo.UpdateStatus(snap.Status.ID, map[string]interface{}{"compress": err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
size := common.LoadSizeUnit(float64(stat.Size()))
|
size := common.LoadSizeUnit2F(float64(stat.Size()))
|
||||||
global.LOG.Debugf("compress successful! size of file: %s", size)
|
global.LOG.Debugf("compress successful! size of file: %s", size)
|
||||||
snap.Status.Compress = constant.StatusDone
|
snap.Status.Compress = constant.StatusDone
|
||||||
snap.Status.Size = size
|
snap.Status.Size = size
|
||||||
|
@ -147,6 +147,16 @@ func RemoveRepeatElement(a interface{}) (ret []interface{}) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func LoadSizeUnit(value float64) string {
|
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 {
|
if value > 1073741824 {
|
||||||
return fmt.Sprintf("%.2fG", value/1073741824)
|
return fmt.Sprintf("%.2fG", value/1073741824)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user