diff --git a/lib/SystemStatistics.php b/lib/SystemStatistics.php index f3ce0721..1dd2865f 100644 --- a/lib/SystemStatistics.php +++ b/lib/SystemStatistics.php @@ -24,6 +24,7 @@ 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 @@ public function getSystemStatistics() { '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 @@ protected function getProcessorUsage() { '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 6806a80e..1fef1ba9 100644 --- a/templates/settings-admin.php +++ b/templates/settings-admin.php @@ -151,8 +151,9 @@ function FormatMegabytes($byte) {
t('Files:')); ?>
t('Storages:')); ?>
-t('Free Space:')); ?> -
+ +t('Free Space:')); ?>
+