summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCaleb Bassi <calebjbassi@gmail.com>2018-12-09 21:11:03 -0800
committerCaleb Bassi <calebjbassi@gmail.com>2018-12-09 21:11:03 -0800
commit7e9de44b3aeb0a74a459d9c587699791e2c7dd2a (patch)
treed65cf7c94a5a4b78ae7aca8e8722f4697c713341
parentb0bf304b67d73a05ea14c20d543861ad57d79e13 (diff)
Cleanup logic to trim 'dev' from disk partition
-rw-r--r--src/widgets/disk.go16
1 files changed, 7 insertions, 9 deletions
diff --git a/src/widgets/disk.go b/src/widgets/disk.go
index 8a7e8c1..c3a85f6 100644
--- a/src/widgets/disk.go
+++ b/src/widgets/disk.go
@@ -60,15 +60,14 @@ func (self *Disk) update() {
// add partition if it's new
for _, Part := range Partitions {
- device := strings.Replace(Part.Device, "/dev/", "", -1)
// don't show loop devices
- if strings.HasPrefix(device, "loop") {
+ if strings.HasPrefix(Part.Device, "loop") {
continue
}
// check if partition doesn't already exist in our list
- if _, ok := self.Partitions[device]; !ok {
- self.Partitions[device] = &Partition{
- Device: device,
+ if _, ok := self.Partitions[Part.Device]; !ok {
+ self.Partitions[Part.Device] = &Partition{
+ Device: Part.Device,
Mount: Part.Mountpoint,
}
}
@@ -79,8 +78,7 @@ func (self *Disk) update() {
for key := range self.Partitions {
exists := false
for _, Part := range Partitions {
- device := strings.Replace(Part.Device, "/dev/", "", -1)
- if key == device {
+ if key == Part.Device {
exists = true
break
}
@@ -105,7 +103,7 @@ func (self *Disk) update() {
Free, Mag := utils.ConvertBytes(usage.Free)
Part.Free = fmt.Sprintf("%3d%s", uint64(Free), Mag)
- ret, err := psDisk.IOCounters("/dev/" + Part.Device)
+ ret, err := psDisk.IOCounters(Part.Device)
if err != nil {
log.Printf("failed to get partition read/write info from gopsutil: %v. Part: %v", err, Part)
continue
@@ -139,7 +137,7 @@ func (self *Disk) update() {
for i, key := range sortedPartitions {
Part := self.Partitions[key]
self.Rows[i] = make([]string, 6)
- self.Rows[i][0] = Part.Device
+ self.Rows[i][0] = strings.Replace(Part.Device, "/dev/", "", -1)
self.Rows[i][1] = Part.Mount
self.Rows[i][2] = fmt.Sprintf("%d%%", Part.UsedPercent)
self.Rows[i][3] = Part.Free