From 3da45428b6585bcc3019f2a2f296a23aa1ed6323 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Mon, 28 Mar 2022 15:32:34 +0200 Subject: [PATCH] dont re-query fileinfo when getting dav quota Signed-off-by: Robin Appelman --- apps/dav/lib/Connector/Sabre/Directory.php | 3 +-- apps/dav/tests/unit/Connector/Sabre/DirectoryTest.php | 8 -------- 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 3ae4416d3632f..bd92b3b22a42d 100644 --- a/apps/dav/lib/Connector/Sabre/Directory.php +++ b/apps/dav/lib/Connector/Sabre/Directory.php @@ -327,8 +327,7 @@ public function getQuotaInfo() { 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 024a6432d0132..c88d2302bec09 100644 --- a/apps/dav/tests/unit/Connector/Sabre/DirectoryTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/DirectoryTest.php @@ -299,10 +299,6 @@ public function testGetQuotaInfoUnlimited() { ->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 @@ public function testGetQuotaInfoSpecific() { $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 efb9252e3462d..547ffef86071d 100644 --- a/lib/private/legacy/OC_Helper.php +++ b/lib/private/legacy/OC_Helper.php @@ -485,7 +485,7 @@ public static function findBinaryPath($program) { * @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 @@ public static function getStorageInfo($path, $rootInfo = null) { if (!$rootInfo instanceof \OCP\Files\FileInfo) { throw new \OCP\Files\NotFoundException(); } - $used = $rootInfo->getSize(); + $used = $rootInfo->getSize($includeMountPoints); if ($used < 0) { $used = 0; }