Commit 396cfda76562fa0277fc499c8031eb17c0c36cb4

Authored by Kevin Fourie
1 parent 5cf5ba27

KTS-2748

"Wrong filesize units at DiskUsageDashlet and zero-byte lines"

Fixed. Corrected parition and filesize methods and catered to 0 size file.

Committed By: Kevin Fourie
Reviewed By: Jonathan Byrne

git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@7777 c91229c3-7414-0410-bfa2-8a42b809f60b
lib/util/ktutil.inc
@@ -44,8 +44,10 @@ class KTUtil { @@ -44,8 +44,10 @@ class KTUtil {
44 const HOUR_IN_SECS = 3600; 44 const HOUR_IN_SECS = 3600;
45 const DAY_IN_SECS = 86400; 45 const DAY_IN_SECS = 86400;
46 const KB = 1024; 46 const KB = 1024;
47 - const MB = 1048576;  
48 - const GB = 1073741824; 47 + const MB = 1048576;
  48 + const GB = 1073741824;
  49 + const TB = 1099511627776;
  50 + const PB = 1125899906842624;
49 51
50 static function computePeriod($diff, $suffix = null, $returnArray=false) 52 static function computePeriod($diff, $suffix = null, $returnArray=false)
51 { 53 {
@@ -89,21 +91,29 @@ class KTUtil { @@ -89,21 +91,29 @@ class KTUtil {
89 { 91 {
90 $filesize = (int) $filesize; 92 $filesize = (int) $filesize;
91 93
92 - if ($filesize >= KTutil::GB) 94 + if ($filesize >= KTutil::PB)
93 { 95 {
94 - return number_format($filesize / KTutil::GB, 2, '.',',') . _kt('GB'); 96 + return number_format($filesize / KTutil::PETA, 2, '.',',') . _kt('EB');
  97 + }
  98 + elseif ($filesize >= KTutil::TB)
  99 + {
  100 + return number_format($filesize / KTutil::TERA, 2, '.',',') . _kt('PB');
  101 + }
  102 + elseif ($filesize >= KTutil::GB)
  103 + {
  104 + return number_format($filesize / KTutil::GIGA, 2, '.',',') . _kt('TB');
95 } 105 }
96 elseif ($filesize >= KTutil::MB) 106 elseif ($filesize >= KTutil::MB)
97 { 107 {
98 - return number_format($filesize / KTutil::MB, 2, '.',',') . _kt('MB'); 108 + return number_format($filesize / KTutil::MEGA, 2, '.',',') . _kt('GB');
99 } 109 }
100 elseif ($filesize >= KTutil::KB) 110 elseif ($filesize >= KTutil::KB)
101 { 111 {
102 - return number_format($filesize / KTutil::KB, 2, '.',',') . _kt('KB'); 112 + return number_format($filesize / KTutil::KILO, 2, '.',',') . _kt('MB');
103 } 113 }
104 else 114 else
105 { 115 {
106 - return $filesize . _kt('b'); 116 + return $filesize . _kt('KB');
107 } 117 }
108 } 118 }
109 119
plugins/housekeeper/DiskUsageDashlet.inc.php
@@ -106,6 +106,8 @@ class DiskUsageDashlet extends KTBaseDashlet @@ -106,6 +106,8 @@ class DiskUsageDashlet extends KTBaseDashlet
106 preg_match('/(.*)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\%\s+(.*)/', $line, $matches); 106 preg_match('/(.*)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\%\s+(.*)/', $line, $matches);
107 list($line, $filesystem, $size, $used, $avail, $usedp, $mount) = $matches; 107 list($line, $filesystem, $size, $used, $avail, $usedp, $mount) = $matches;
108 108
  109 + if ($size === 0) continue;
  110 +
109 if ($usedp >= 100 - $this->urgentPercent) 111 if ($usedp >= 100 - $this->urgentPercent)
110 { 112 {
111 $colour = 'red'; 113 $colour = 'red';
plugins/housekeeper/FolderUsageDashlet.inc.php
@@ -131,7 +131,7 @@ class FolderUsageDashlet extends KTBaseDashlet @@ -131,7 +131,7 @@ class FolderUsageDashlet extends KTBaseDashlet
131 'description'=>$name, 131 'description'=>$name,
132 'folder'=>$directory, 132 'folder'=>$directory,
133 'files'=>number_format($temp['files'],0,'.',','), 133 'files'=>number_format($temp['files'],0,'.',','),
134 - 'filesize'=>KTUtil::filesizeToString($temp['filesize']), 134 + 'filesize'=>KTUtil::filesizeToString($temp['filesize']/1024),
135 'action'=>$i, 135 'action'=>$i,
136 'canClean'=>$canClean 136 'canClean'=>$canClean
137 ); 137 );