Allow passing a root folder to get the used space from in the quota wrapper

This commit is contained in:
Robin Appelman 2014-01-27 15:41:56 +01:00
parent d182b4f59f
commit a521949baf
2 changed files with 8 additions and 2 deletions

View File

@ -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 {

View File

@ -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'));
}
}