Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/serverinfo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDaniel Kesselberg <mail@danielkesselberg.de>2020-03-16 17:22:41 +0300
committerDaniel Kesselberg <mail@danielkesselberg.de>2020-03-17 22:33:39 +0300
commit4a816d12bab225360eefbe3c2e466f16d5e98714 (patch)
tree0ec8fac06ea755118ec4b033d3d1abea1de41317 /lib
parent0e77103f4ec86f037858ee4a59a4e5afc88f0e09 (diff)
Fix FormatBytes expects kB instead of bytes
I guess the confusion was the df -TP already returns the values as kB instead of bytes hence we have to multiply the values first before we pass them to FormatBytes. Signed-off-by: Daniel Kesselberg <mail@danielkesselberg.de>
Diffstat (limited to 'lib')
-rw-r--r--lib/Controller/ApiController.php1
-rw-r--r--lib/OperatingSystems/DefaultOs.php6
-rw-r--r--lib/Os.php24
3 files changed, 16 insertions, 15 deletions
diff --git a/lib/Controller/ApiController.php b/lib/Controller/ApiController.php
index 455fa4a..33be7a0 100644
--- a/lib/Controller/ApiController.php
+++ b/lib/Controller/ApiController.php
@@ -167,7 +167,6 @@ class ApiController extends OCSController {
if ($interval->d > 0) {
return $interval->format('%d days, %h hours, %i minutes, %s seconds');
}
-
return $interval->format('%h hours, %i minutes, %s seconds');
}
}
diff --git a/lib/OperatingSystems/DefaultOs.php b/lib/OperatingSystems/DefaultOs.php
index ebc6dc1..c232031 100644
--- a/lib/OperatingSystems/DefaultOs.php
+++ b/lib/OperatingSystems/DefaultOs.php
@@ -75,7 +75,7 @@ class DefaultOs {
$unit = $units[$i];
if ($unit === 'kB') {
- $value *= 1000;
+ $value *= 1024;
}
$data[$key] = $value;
@@ -223,8 +223,8 @@ class DefaultOs {
$items = [];
$items['device'] = $entry[0];
$items['fs'] = $entry[1];
- $items['used'] = $entry[3];
- $items['available'] = $entry[4];
+ $items['used'] = $entry[3] * 1024;
+ $items['available'] = $entry[4] * 1024;
$items['percent'] = $entry[5];
$items['mount'] = $entry[6];
$result[] = $items;
diff --git a/lib/Os.php b/lib/Os.php
index 231727b..eebbf8c 100644
--- a/lib/Os.php
+++ b/lib/Os.php
@@ -144,23 +144,25 @@ class Os {
}
/**
- * @return string
+ * Get diskdata will return a numerical list with two elements for each disk (used and available) where all values are in gigabyte.
+ * [
+ * [used => 0, available => 0],
+ * [used => 0, available => 0],
+ * ]
+ *
+ * @return array
*/
- public function getDiskData() {
+ public function getDiskData(): array {
+ $data = [];
$disks = $this->backend->getDiskInfo();
- $data = array();
- $i = 0;
+
foreach ($disks as $disk) {
- $data[$i] = [
- round(($disk['used']) / 1024 / 1024, 1),
- round($disk['available'] / 1024 / 1024, 1)
+ $data[] = [
+ round($disk['used'] / 1024 / 1024 / 1024, 1),
+ round($disk['available'] / 1024 / 1024 / 1024, 1)
];
- $i++;
}
-// debug data
- // $data = array('0'=>array(1,2),'1'=>array(4,5),'2'=>array(3,1));
-
return $data;
}