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
diff options
context:
space:
mode:
authorkesselb <mail@danielkesselberg.de>2021-05-20 19:18:11 +0300
committerGitHub <noreply@github.com>2021-05-20 19:18:11 +0300
commitb434b1e672bba5603bc6d0d77edc959be12eed2f (patch)
tree9a930713bc250873b737600e4a0746c552e6abd4
parenteacd5976f3dd640a5d850df1fc551102dd6c5481 (diff)
parent87f84d14675fd90c92489925d101a7c85f556ff8 (diff)
Merge pull request #295 from nextcloud/backport/294/stable21
[stable21] Hide free space if it can't be calculated
-rw-r--r--lib/SystemStatistics.php19
-rw-r--r--templates/settings-admin.php5
2 files changed, 21 insertions, 3 deletions
diff --git a/lib/SystemStatistics.php b/lib/SystemStatistics.php
index f3ce072..1dd2865 100644
--- a/lib/SystemStatistics.php
+++ b/lib/SystemStatistics.php
@@ -24,6 +24,7 @@ namespace OCA\ServerInfo;
use OC\Files\View;
use OC\Installer;
+use OCP\Files\FileInfo;
use OCP\IConfig;
use OCP\App\IAppManager;
use bantu\IniGetWrapper\IniGetWrapper;
@@ -77,7 +78,7 @@ class SystemStatistics {
'filelocking.enabled' => $this->config->getSystemValue('filelocking.enabled', true) ? 'yes' : 'no',
'memcache.locking' => $this->config->getSystemValue('memcache.locking', 'none'),
'debug' => $this->config->getSystemValue('debug', false) ? 'yes' : 'no',
- 'freespace' => $this->view->free_space(),
+ 'freespace' => $this->getFreeSpace(),
'cpuload' => $processorUsage['loadavg'],
'mem_total' => $memoryUsage['mem_total'],
'mem_free' => $memoryUsage['mem_free'],
@@ -222,4 +223,20 @@ class SystemStatistics {
'loadavg' => $loadavg
];
}
+
+ /**
+ * Get free space if it can be calculated.
+ *
+ * @return mixed free space or null
+ * @throws \OCP\Files\InvalidPathException
+ */
+ protected function getFreeSpace() {
+ $free_space = $this->view->free_space();
+ if ($free_space === FileInfo::SPACE_UNKNOWN
+ || $free_space === FileInfo::SPACE_UNLIMITED
+ || $free_space === FileInfo::SPACE_NOT_COMPUTED) {
+ return null;
+ }
+ return $free_space;
+ }
}
diff --git a/templates/settings-admin.php b/templates/settings-admin.php
index 6eeefdd..49863b9 100644
--- a/templates/settings-admin.php
+++ b/templates/settings-admin.php
@@ -151,8 +151,9 @@ $disks = $_['diskinfo'];
<p><?php p($l->t('Files:')); ?> <strong id="numFilesStorage"><?php p($_['storage']['num_files']); ?></strong></p>
<p><?php p($l->t('Storages:')); ?> <strong id="numFilesStorages"><?php p($_['storage']['num_storages']); ?></strong></p>
- <p><?php p($l->t('Free Space:')); ?> <strong id="systemDiskFreeSpace"><?php p($_['system']['freespace']); ?></strong>
- </p>
+ <?php if ($_['system']['freespace'] !== null): ?>
+ <p><?php p($l->t('Free Space:')); ?> <strong id="systemDiskFreeSpace"><?php p($_['system']['freespace']); ?></strong></p>
+ <?php endif; ?>
</div>
<!-- NETWORK -->