Changeset View
Changeset View
Standalone View
Standalone View
lib/api/quota.php
Show All 25 Lines | |||||
{ | { | ||||
/** | /** | ||||
* Request handler | * Request handler | ||||
*/ | */ | ||||
public function handle() | public function handle() | ||||
{ | { | ||||
parent::handle(); | parent::handle(); | ||||
list($driver, $path) = $this->api->get_driver($this->args['folder']); | list($driver, $path) = $this->api->get_driver($this->args['folder'] ?? null); | ||||
$quota = $driver->quota($path); | $quota = $driver->quota($path); | ||||
if (!$quota['total']) { | if (!($quota['total'] ?? false)) { | ||||
$quota['percent'] = 0; | $quota['percent'] = 0; | ||||
} | } | ||||
else if ($quota['total']) { | else if ($quota['total'] ?? false) { | ||||
if (!isset($quota['percent'])) { | if (!isset($quota['percent'])) { | ||||
$quota['percent'] = min(100, round(($quota['used']/max(1, $quota['total']))*100)); | $quota['percent'] = min(100, round(($quota['used']/max(1, $quota['total']))*100)); | ||||
} | } | ||||
} | } | ||||
return $quota; | return $quota; | ||||
} | } | ||||
} | } |