diff options
author | Robin Appelman <robin@icewind.nl> | 2020-03-04 18:02:50 +0100 |
---|---|---|
committer | backportbot[bot] <backportbot[bot]@users.noreply.github.com> | 2020-03-25 13:19:01 +0000 |
commit | 7e55adcdf721c516f0f0f97ae00cf052f707e6cd (patch) | |
tree | ed98ec1a4018ae4a8de644fb42e9d009317833bd | |
parent | dcf186d9ef7a65865d19865a10169ff98fc3db73 (diff) | |
download | nextcloud-server-7e55adcdf721c516f0f0f97ae00cf052f707e6cd.tar.gz nextcloud-server-7e55adcdf721c516f0f0f97ae00cf052f707e6cd.zip |
Use global used space in quota wrappen when external storage is included
Signed-off-by: Robin Appelman <robin@icewind.nl>
-rw-r--r-- | lib/private/Files/Storage/Wrapper/Quota.php | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/lib/private/Files/Storage/Wrapper/Quota.php b/lib/private/Files/Storage/Wrapper/Quota.php index 492b5aba436..a71d5bdf61e 100644 --- a/lib/private/Files/Storage/Wrapper/Quota.php +++ b/lib/private/Files/Storage/Wrapper/Quota.php @@ -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(); - } else { - $cache = $storage->getCache(); - } - $data = $cache->get($path); - if ($data instanceof ICacheEntry and isset($data['size'])) { - return $data['size']; + if ($this->config->getValue('quota_include_external_storage', false)) { + $rootInfo = Filesystem::getFileInfo('', 'ext'); + return $rootInfo->getSize(true); } 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; + } } } |