mirror of
https://github.com/nextcloud/server.git
synced 2024-07-25 13:54:59 +02:00
Allow passing a root folder to get the used space from in the quota wrapper
This commit is contained in:
parent
d182b4f59f
commit
a521949baf
@ -15,12 +15,18 @@ class Quota extends Wrapper {
|
||||
*/
|
||||
protected $quota;
|
||||
|
||||
/**
|
||||
* @var string $freeSpaceRoot
|
||||
*/
|
||||
protected $sizeRoot;
|
||||
|
||||
/**
|
||||
* @param array $parameters
|
||||
*/
|
||||
public function __construct($parameters) {
|
||||
$this->storage = $parameters['storage'];
|
||||
$this->quota = $parameters['quota'];
|
||||
$this->freeSpaceRoot = isset($parameters['root']) ? $parameters['root'] : '';
|
||||
}
|
||||
|
||||
protected function getSize($path) {
|
||||
@ -43,7 +49,7 @@ class Quota extends Wrapper {
|
||||
if ($this->quota < 0) {
|
||||
return $this->storage->free_space($path);
|
||||
} else {
|
||||
$used = $this->getSize('');
|
||||
$used = $this->getSize($this->freeSpaceRoot);
|
||||
if ($used < 0) {
|
||||
return \OC\Files\SPACE_NOT_COMPUTED;
|
||||
} else {
|
||||
|
@ -65,7 +65,7 @@ class OC_Util {
|
||||
$user = $storage->getUser()->getUID();
|
||||
$quota = OC_Util::getUserQuota($user);
|
||||
if ($quota !== \OC\Files\SPACE_UNLIMITED) {
|
||||
return new \OC\Files\Storage\Wrapper\Quota(array('storage' => $storage, 'quota' => $quota));
|
||||
return new \OC\Files\Storage\Wrapper\Quota(array('storage' => $storage, 'quota' => $quota, 'root' => 'files'));
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user