diff options
-rw-r--r-- | lib/SystemStatistics.php | 19 | ||||
-rw-r--r-- | templates/settings-admin.php | 5 |
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 --> |