Merge pull request #20164 from nextcloud/backport/19782/stable17

[stable17] Use global used space in quota wrappen when external storage is included
This commit is contained in:
Morris Jobke 2020-04-14 13:59:48 +02:00 committed by GitHub
commit d29658f046
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -27,6 +27,7 @@
namespace OC\Files\Storage\Wrapper;
use OC\Files\Filesystem;
use OCP\Files\Cache\ICacheEntry;
use OCP\Files\Storage\IStorage;
@ -42,6 +43,8 @@ class Quota extends Wrapper {
*/
protected $sizeRoot;
private $config;
/**
* @param array $parameters
*/
@ -49,6 +52,7 @@ class Quota extends Wrapper {
parent::__construct($parameters);
$this->quota = $parameters['quota'];
$this->sizeRoot = isset($parameters['root']) ? $parameters['root'] : '';
$this->config = \OC::$server->getSystemConfig();
}
/**
@ -63,16 +67,21 @@ class Quota extends Wrapper {
* @param \OC\Files\Storage\Storage $storage
*/
protected function getSize($path, $storage = null) {
if (is_null($storage)) {
$cache = $this->getCache();
if ($this->config->getValue('quota_include_external_storage', false)) {
$rootInfo = Filesystem::getFileInfo('', 'ext');
return $rootInfo->getSize(true);
} else {
$cache = $storage->getCache();
}
$data = $cache->get($path);
if ($data instanceof ICacheEntry and isset($data['size'])) {
return $data['size'];
} else {
return \OCP\Files\FileInfo::SPACE_NOT_COMPUTED;
if (is_null($storage)) {
$cache = $this->getCache();
} else {
$cache = $storage->getCache();
}
$data = $cache->get($path);
if ($data instanceof ICacheEntry and isset($data['size'])) {
return $data['size'];
} else {
return \OCP\Files\FileInfo::SPACE_NOT_COMPUTED;
}
}
}