mirror of
https://github.com/goharbor/harbor.git
synced 2024-11-22 18:25:56 +01:00
Fix volume capacity when run in MacOS
Signed-off-by: 陈德 <chende@caicloud.io>
This commit is contained in:
parent
3e750ad6b6
commit
ecadd564b1
@ -17,7 +17,7 @@ package imagestorage
|
||||
// GlobalDriver is a global image storage driver
|
||||
var GlobalDriver Driver
|
||||
|
||||
// Capacity holds information about capaticy of image storage
|
||||
// Capacity holds information about capacity of image storage
|
||||
type Capacity struct {
|
||||
// total size(byte)
|
||||
Total uint64 `json:"total"`
|
||||
|
@ -16,6 +16,7 @@ package filesystem
|
||||
|
||||
import (
|
||||
"os"
|
||||
"reflect"
|
||||
"syscall"
|
||||
|
||||
storage "github.com/vmware/harbor/src/adminserver/systeminfo/imagestorage"
|
||||
@ -56,8 +57,18 @@ func (d *driver) Cap() (*storage.Capacity, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
bSize := uint64(stat.Bsize)
|
||||
field := reflect.ValueOf(&stat).Elem().FieldByName("Frsize")
|
||||
if field.IsValid() {
|
||||
if field.Kind() == reflect.Uint64 {
|
||||
bSize = field.Uint()
|
||||
} else {
|
||||
bSize = uint64(field.Int())
|
||||
}
|
||||
}
|
||||
|
||||
return &storage.Capacity{
|
||||
Total: stat.Blocks * uint64(stat.Bsize),
|
||||
Free: stat.Bavail * uint64(stat.Bsize),
|
||||
Total: stat.Blocks * bSize,
|
||||
Free: stat.Bavail * bSize,
|
||||
}, nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user