Skip to content

Commit 87f84d1

Browse files
committed
Hide free space if it can't be calculated
Signed-off-by: Richard Steinmetz <richard@steinmetz.cloud>
1 parent eacd597 commit 87f84d1

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

lib/SystemStatistics.php

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
use OC\Files\View;
2626
use OC\Installer;
27+
use OCP\Files\FileInfo;
2728
use OCP\IConfig;
2829
use OCP\App\IAppManager;
2930
use bantu\IniGetWrapper\IniGetWrapper;
@@ -77,7 +78,7 @@ public function getSystemStatistics() {
7778
'filelocking.enabled' => $this->config->getSystemValue('filelocking.enabled', true) ? 'yes' : 'no',
7879
'memcache.locking' => $this->config->getSystemValue('memcache.locking', 'none'),
7980
'debug' => $this->config->getSystemValue('debug', false) ? 'yes' : 'no',
80-
'freespace' => $this->view->free_space(),
81+
'freespace' => $this->getFreeSpace(),
8182
'cpuload' => $processorUsage['loadavg'],
8283
'mem_total' => $memoryUsage['mem_total'],
8384
'mem_free' => $memoryUsage['mem_free'],
@@ -222,4 +223,20 @@ protected function getProcessorUsage() {
222223
'loadavg' => $loadavg
223224
];
224225
}
226+
227+
/**
228+
* Get free space if it can be calculated.
229+
*
230+
* @return mixed free space or null
231+
* @throws \OCP\Files\InvalidPathException
232+
*/
233+
protected function getFreeSpace() {
234+
$free_space = $this->view->free_space();
235+
if ($free_space === FileInfo::SPACE_UNKNOWN
236+
|| $free_space === FileInfo::SPACE_UNLIMITED
237+
|| $free_space === FileInfo::SPACE_NOT_COMPUTED) {
238+
return null;
239+
}
240+
return $free_space;
241+
}
225242
}

templates/settings-admin.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,9 @@ function FormatMegabytes($byte) {
151151

152152
<p><?php p($l->t('Files:')); ?> <strong id="numFilesStorage"><?php p($_['storage']['num_files']); ?></strong></p>
153153
<p><?php p($l->t('Storages:')); ?> <strong id="numFilesStorages"><?php p($_['storage']['num_storages']); ?></strong></p>
154-
<p><?php p($l->t('Free Space:')); ?> <strong id="systemDiskFreeSpace"><?php p($_['system']['freespace']); ?></strong>
155-
</p>
154+
<?php if ($_['system']['freespace'] !== null): ?>
155+
<p><?php p($l->t('Free Space:')); ?> <strong id="systemDiskFreeSpace"><?php p($_['system']['freespace']); ?></strong></p>
156+
<?php endif; ?>
156157
</div>
157158

158159
<!-- NETWORK -->

0 commit comments

Comments
 (0)