diff options
author | Robin Appelman <robin@icewind.nl> | 2022-04-04 22:02:54 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-04 22:02:54 +0300 |
commit | ccc348246827555e71b8978e35d4ac11b902c2a8 (patch) | |
tree | 99449678ee3aba9fce6547cefdeb314179f9e5ba | |
parent | a44671d3968a889f23b74194341dd7688b9ff5a3 (diff) | |
parent | 5ae6cefd57b2374802b428f9e03c60ba951c5607 (diff) |
Merge pull request #31734 from nextcloud/dav-quota-dont-query
dont re-query fileinfo when getting dav quota
-rw-r--r-- | apps/dav/lib/Connector/Sabre/Directory.php | 3 | ||||
-rw-r--r-- | apps/dav/tests/unit/Connector/Sabre/DirectoryTest.php | 8 | ||||
-rw-r--r-- | lib/private/legacy/OC_Helper.php | 4 |
3 files changed, 3 insertions, 12 deletions
diff --git a/apps/dav/lib/Connector/Sabre/Directory.php b/apps/dav/lib/Connector/Sabre/Directory.php index 3ae4416d363..bd92b3b22a4 100644 --- a/apps/dav/lib/Connector/Sabre/Directory.php +++ b/apps/dav/lib/Connector/Sabre/Directory.php @@ -327,8 +327,7 @@ class Directory extends \OCA\DAV\Connector\Sabre\Node implements \Sabre\DAV\ICol return $this->quotaInfo; } try { - $info = $this->fileView->getFileInfo($this->path, false); - $storageInfo = \OC_Helper::getStorageInfo($this->info->getPath(), $info); + $storageInfo = \OC_Helper::getStorageInfo($this->info->getPath(), $this->info, false); if ($storageInfo['quota'] === \OCP\Files\FileInfo::SPACE_UNLIMITED) { $free = \OCP\Files\FileInfo::SPACE_UNLIMITED; } else { diff --git a/apps/dav/tests/unit/Connector/Sabre/DirectoryTest.php b/apps/dav/tests/unit/Connector/Sabre/DirectoryTest.php index 024a6432d01..c88d2302bec 100644 --- a/apps/dav/tests/unit/Connector/Sabre/DirectoryTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/DirectoryTest.php @@ -299,10 +299,6 @@ class DirectoryTest extends \Test\TestCase { ->method('getMountPoint') ->willReturn($mountPoint); - $this->view->expects($this->once()) - ->method('getFileInfo') - ->willReturn($this->info); - $mountPoint->method('getMountPoint') ->willReturn('/user/files/mymountpoint'); @@ -344,10 +340,6 @@ class DirectoryTest extends \Test\TestCase { $mountPoint->method('getMountPoint') ->willReturn('/user/files/mymountpoint'); - $this->view->expects($this->once()) - ->method('getFileInfo') - ->willReturn($this->info); - $dir = new Directory($this->view, $this->info); $this->assertEquals([200, 800], $dir->getQuotaInfo()); //200 used, 800 free } diff --git a/lib/private/legacy/OC_Helper.php b/lib/private/legacy/OC_Helper.php index efb9252e346..547ffef8607 100644 --- a/lib/private/legacy/OC_Helper.php +++ b/lib/private/legacy/OC_Helper.php @@ -485,7 +485,7 @@ class OC_Helper { * @return array * @throws \OCP\Files\NotFoundException */ - public static function getStorageInfo($path, $rootInfo = null) { + public static function getStorageInfo($path, $rootInfo = null, $includeMountPoints = true) { // return storage info without adding mount points $includeExtStorage = \OC::$server->getSystemConfig()->getValue('quota_include_external_storage', false); @@ -495,7 +495,7 @@ class OC_Helper { if (!$rootInfo instanceof \OCP\Files\FileInfo) { throw new \OCP\Files\NotFoundException(); } - $used = $rootInfo->getSize(); + $used = $rootInfo->getSize($includeMountPoints); if ($used < 0) { $used = 0; } |