Signed-off-by: Tatsushi Inagaki <e29253@jp.ibm.com>
| ... | ... |
@@ -1052,7 +1052,7 @@ func (cli *DockerCli) CmdHistory(args ...string) error {
|
| 1052 | 1052 |
} else {
|
| 1053 | 1053 |
fmt.Fprintf(w, "%s\t", utils.Trunc(out.Get("CreatedBy"), 45))
|
| 1054 | 1054 |
} |
| 1055 |
- fmt.Fprintf(w, "%s\n", units.HumanSize(out.GetInt64("Size")))
|
|
| 1055 |
+ fmt.Fprintf(w, "%s\n", units.HumanSize(float64(out.GetInt64("Size"))))
|
|
| 1056 | 1056 |
} else {
|
| 1057 | 1057 |
if *noTrunc {
|
| 1058 | 1058 |
fmt.Fprintln(w, outID) |
| ... | ... |
@@ -1451,7 +1451,7 @@ func (cli *DockerCli) CmdImages(args ...string) error {
|
| 1451 | 1451 |
} |
| 1452 | 1452 |
|
| 1453 | 1453 |
if !*quiet {
|
| 1454 |
- fmt.Fprintf(w, "%s\t%s\t%s\t%s ago\t%s\n", repo, tag, outID, units.HumanDuration(time.Now().UTC().Sub(time.Unix(out.GetInt64("Created"), 0))), units.HumanSize(out.GetInt64("VirtualSize")))
|
|
| 1454 |
+ fmt.Fprintf(w, "%s\t%s\t%s\t%s ago\t%s\n", repo, tag, outID, units.HumanDuration(time.Now().UTC().Sub(time.Unix(out.GetInt64("Created"), 0))), units.HumanSize(float64(out.GetInt64("VirtualSize"))))
|
|
| 1455 | 1455 |
} else {
|
| 1456 | 1456 |
fmt.Fprintln(w, outID) |
| 1457 | 1457 |
} |
| ... | ... |
@@ -1525,7 +1525,7 @@ func (cli *DockerCli) printTreeNode(noTrunc bool, image *engine.Env, prefix stri |
| 1525 | 1525 |
imageID = utils.TruncateID(image.Get("Id"))
|
| 1526 | 1526 |
} |
| 1527 | 1527 |
|
| 1528 |
- fmt.Fprintf(cli.out, "%s%s Virtual Size: %s", prefix, imageID, units.HumanSize(image.GetInt64("VirtualSize")))
|
|
| 1528 |
+ fmt.Fprintf(cli.out, "%s%s Virtual Size: %s", prefix, imageID, units.HumanSize(float64(image.GetInt64("VirtualSize"))))
|
|
| 1529 | 1529 |
if image.GetList("RepoTags")[0] != "<none>:<none>" {
|
| 1530 | 1530 |
fmt.Fprintf(cli.out, " Tags: %s\n", strings.Join(image.GetList("RepoTags"), ", "))
|
| 1531 | 1531 |
} else {
|
| ... | ... |
@@ -1668,9 +1668,9 @@ func (cli *DockerCli) CmdPs(args ...string) error {
|
| 1668 | 1668 |
|
| 1669 | 1669 |
if *size {
|
| 1670 | 1670 |
if out.GetInt("SizeRootFs") > 0 {
|
| 1671 |
- fmt.Fprintf(w, "%s (virtual %s)\n", units.HumanSize(out.GetInt64("SizeRw")), units.HumanSize(out.GetInt64("SizeRootFs")))
|
|
| 1671 |
+ fmt.Fprintf(w, "%s (virtual %s)\n", units.HumanSize(float64(out.GetInt64("SizeRw"))), units.HumanSize(float64(out.GetInt64("SizeRootFs"))))
|
|
| 1672 | 1672 |
} else {
|
| 1673 |
- fmt.Fprintf(w, "%s\n", units.HumanSize(out.GetInt64("SizeRw")))
|
|
| 1673 |
+ fmt.Fprintf(w, "%s\n", units.HumanSize(float64(out.GetInt64("SizeRw"))))
|
|
| 1674 | 1674 |
} |
| 1675 | 1675 |
|
| 1676 | 1676 |
continue |
| ... | ... |
@@ -56,13 +56,13 @@ func (d *Driver) Status() [][2]string {
|
| 56 | 56 |
|
| 57 | 57 |
status := [][2]string{
|
| 58 | 58 |
{"Pool Name", s.PoolName},
|
| 59 |
- {"Pool Blocksize", fmt.Sprintf("%s", units.HumanSize(int64(s.SectorSize)))},
|
|
| 59 |
+ {"Pool Blocksize", fmt.Sprintf("%s", units.HumanSize(float64(s.SectorSize)))},
|
|
| 60 | 60 |
{"Data file", s.DataLoopback},
|
| 61 | 61 |
{"Metadata file", s.MetadataLoopback},
|
| 62 |
- {"Data Space Used", fmt.Sprintf("%s", units.HumanSize(int64(s.Data.Used)))},
|
|
| 63 |
- {"Data Space Total", fmt.Sprintf("%s", units.HumanSize(int64(s.Data.Total)))},
|
|
| 64 |
- {"Metadata Space Used", fmt.Sprintf("%s", units.HumanSize(int64(s.Metadata.Used)))},
|
|
| 65 |
- {"Metadata Space Total", fmt.Sprintf("%s", units.HumanSize(int64(s.Metadata.Total)))},
|
|
| 62 |
+ {"Data Space Used", fmt.Sprintf("%s", units.HumanSize(float64(s.Data.Used)))},
|
|
| 63 |
+ {"Data Space Total", fmt.Sprintf("%s", units.HumanSize(float64(s.Data.Total)))},
|
|
| 64 |
+ {"Metadata Space Used", fmt.Sprintf("%s", units.HumanSize(float64(s.Metadata.Used)))},
|
|
| 65 |
+ {"Metadata Space Total", fmt.Sprintf("%s", units.HumanSize(float64(s.Metadata.Total)))},
|
|
| 66 | 66 |
} |
| 67 | 67 |
if vStr, err := devicemapper.GetLibraryVersion(); err == nil {
|
| 68 | 68 |
status = append(status, [2]string{"Library Version", vStr})
|
| ... | ... |
@@ -39,7 +39,7 @@ var binaryAbbrs = []string{"B", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB",
|
| 39 | 39 |
|
| 40 | 40 |
// HumanSize returns a human-readable approximation of a size |
| 41 | 41 |
// using SI standard (eg. "44kB", "17MB") |
| 42 |
-func HumanSize(size int64) string {
|
|
| 42 |
+func HumanSize(size float64) string {
|
|
| 43 | 43 |
return intToString(float64(size), 1000.0, decimapAbbrs) |
| 44 | 44 |
} |
| 45 | 45 |
|
| ... | ... |
@@ -44,11 +44,11 @@ func (p *JSONProgress) String() string {
|
| 44 | 44 |
if p.Current <= 0 && p.Total <= 0 {
|
| 45 | 45 |
return "" |
| 46 | 46 |
} |
| 47 |
- current := units.HumanSize(int64(p.Current)) |
|
| 47 |
+ current := units.HumanSize(float64(p.Current)) |
|
| 48 | 48 |
if p.Total <= 0 {
|
| 49 | 49 |
return fmt.Sprintf("%8v", current)
|
| 50 | 50 |
} |
| 51 |
- total := units.HumanSize(int64(p.Total)) |
|
| 51 |
+ total := units.HumanSize(float64(p.Total)) |
|
| 52 | 52 |
percentage := int(float64(p.Current)/float64(p.Total)*100) / 2 |
| 53 | 53 |
if width > 110 {
|
| 54 | 54 |
// this number can't be negetive gh#7136 |