summaryrefslogtreecommitdiffstats
path: root/lib/private/Files
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2020-04-14 14:08:20 +0200
committerGitHub <noreply@github.com>2020-04-14 14:08:20 +0200
commit276a650d0f6c9d1a32a6affbc0501f08e1772047 (patch)
treea2d789524f259d6f6a1769644f3a0a4828cd4c03 /lib/private/Files
parent69960c860ae0568051be56eb12ccf74be0a59a08 (diff)
parent41a839a63d0ec022da9fee050215f72a7366f6fa (diff)
downloadnextcloud-server-276a650d0f6c9d1a32a6affbc0501f08e1772047.tar.gz
nextcloud-server-276a650d0f6c9d1a32a6affbc0501f08e1772047.zip
Merge pull request #20163 from nextcloud/backport/19782/stable18
[stable18] Use global used space in quota wrappen when external storage is included
Diffstat (limited to 'lib/private/Files')
-rw-r--r--lib/private/Files/Storage/Wrapper/Quota.php27
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 b5a1be95aaf..d4e4be41f71 100644
--- a/lib/private/Files/Storage/Wrapper/Quota.php
+++ b/lib/private/Files/Storage/Wrapper/Quota.php
@@ -29,6 +29,7 @@
namespace OC\Files\Storage\Wrapper;
+use OC\Files\Filesystem;
use OCP\Files\Cache\ICacheEntry;
use OCP\Files\Storage\IStorage;
@@ -44,6 +45,8 @@ class Quota extends Wrapper {
*/
protected $sizeRoot;
+ private $config;
+
/**
* @param array $parameters
*/
@@ -51,6 +54,7 @@ class Quota extends Wrapper {
parent::__construct($parameters);
$this->quota = $parameters['quota'];
$this->sizeRoot = isset($parameters['root']) ? $parameters['root'] : '';
+ $this->config = \OC::$server->getSystemConfig();
}
/**
@@ -65,16 +69,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;
+ }
}
}