Fixes #90. The disk widget was truncating, not rounding
This commit is contained in:
parent
4895f5ec24
commit
dfa7098ad8
|
@ -41,6 +41,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
- Help & statusbar don't obey theme (#47).
|
- Help & statusbar don't obey theme (#47).
|
||||||
- Fix help text layout.
|
- Fix help text layout.
|
||||||
- Merged fix from @markuspeloquin for custom color scheme loading crash
|
- Merged fix from @markuspeloquin for custom color scheme loading crash
|
||||||
|
- Memory line colors were inconsistently assigned (#91)
|
||||||
|
- The disk code was truncating values instead of rounding (#90)
|
||||||
|
|
||||||
## [3.5.1] - 2020-04-09
|
## [3.5.1] - 2020-04-09
|
||||||
|
|
||||||
|
|
|
@ -121,17 +121,16 @@ func (self *DiskWidget) update() {
|
||||||
delete(self.Partitions, device)
|
delete(self.Partitions, device)
|
||||||
}
|
}
|
||||||
|
|
||||||
// updates partition info
|
// updates partition info. We add 0.5 to all values to make sure the truncation rounds
|
||||||
for _, partition := range self.Partitions {
|
for _, partition := range self.Partitions {
|
||||||
usage, err := psDisk.Usage(partition.MountPoint)
|
usage, err := psDisk.Usage(partition.MountPoint)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("failed to get partition usage statistics from gopsutil: %v. partition: %v", err, partition)
|
log.Printf("failed to get partition usage statistics from gopsutil: %v. partition: %v", err, partition)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
partition.UsedPercent = uint32(usage.UsedPercent)
|
partition.UsedPercent = uint32(usage.UsedPercent + 0.5)
|
||||||
|
|
||||||
bytesFree, magnitudeFree := utils.ConvertBytes(usage.Free)
|
bytesFree, magnitudeFree := utils.ConvertBytes(usage.Free)
|
||||||
partition.Free = fmt.Sprintf("%3d%s", uint64(bytesFree), magnitudeFree)
|
partition.Free = fmt.Sprintf("%3d%s", uint64(bytesFree+0.5), magnitudeFree)
|
||||||
|
|
||||||
ioCounters, err := psDisk.IOCounters(partition.Device)
|
ioCounters, err := psDisk.IOCounters(partition.Device)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -146,7 +145,7 @@ func (self *DiskWidget) update() {
|
||||||
|
|
||||||
readFloat, readMagnitude := utils.ConvertBytes(bytesReadRecently)
|
readFloat, readMagnitude := utils.ConvertBytes(bytesReadRecently)
|
||||||
writeFloat, writeMagnitude := utils.ConvertBytes(bytesWrittenRecently)
|
writeFloat, writeMagnitude := utils.ConvertBytes(bytesWrittenRecently)
|
||||||
bytesReadRecently, bytesWrittenRecently = uint64(readFloat), uint64(writeFloat)
|
bytesReadRecently, bytesWrittenRecently = uint64(readFloat+0.5), uint64(writeFloat+0.5)
|
||||||
partition.BytesReadRecently = fmt.Sprintf("%d%s", bytesReadRecently, readMagnitude)
|
partition.BytesReadRecently = fmt.Sprintf("%d%s", bytesReadRecently, readMagnitude)
|
||||||
partition.BytesWrittenRecently = fmt.Sprintf("%d%s", bytesWrittenRecently, writeMagnitude)
|
partition.BytesWrittenRecently = fmt.Sprintf("%d%s", bytesWrittenRecently, writeMagnitude)
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user