Skip to content

Commit ee9ac5b

Browse files
authored
Merge pull request #31836 from nextcloud/backport/31734/stable23
[stable23] dont re-query fileinfo when getting dav quota
2 parents eee279d + 3da4542 commit ee9ac5b

File tree

3 files changed

+3
-12
lines changed

3 files changed

+3
-12
lines changed

apps/dav/lib/Connector/Sabre/Directory.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -327,8 +327,7 @@ public function getQuotaInfo() {
327327
return $this->quotaInfo;
328328
}
329329
try {
330-
$info = $this->fileView->getFileInfo($this->path, false);
331-
$storageInfo = \OC_Helper::getStorageInfo($this->info->getPath(), $info);
330+
$storageInfo = \OC_Helper::getStorageInfo($this->info->getPath(), $this->info, false);
332331
if ($storageInfo['quota'] === \OCP\Files\FileInfo::SPACE_UNLIMITED) {
333332
$free = \OCP\Files\FileInfo::SPACE_UNLIMITED;
334333
} else {

apps/dav/tests/unit/Connector/Sabre/DirectoryTest.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -299,10 +299,6 @@ public function testGetQuotaInfoUnlimited() {
299299
->method('getMountPoint')
300300
->willReturn($mountPoint);
301301

302-
$this->view->expects($this->once())
303-
->method('getFileInfo')
304-
->willReturn($this->info);
305-
306302
$mountPoint->method('getMountPoint')
307303
->willReturn('/user/files/mymountpoint');
308304

@@ -344,10 +340,6 @@ public function testGetQuotaInfoSpecific() {
344340
$mountPoint->method('getMountPoint')
345341
->willReturn('/user/files/mymountpoint');
346342

347-
$this->view->expects($this->once())
348-
->method('getFileInfo')
349-
->willReturn($this->info);
350-
351343
$dir = new Directory($this->view, $this->info);
352344
$this->assertEquals([200, 800], $dir->getQuotaInfo()); //200 used, 800 free
353345
}

lib/private/legacy/OC_Helper.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,7 @@ public static function findBinaryPath($program) {
485485
* @return array
486486
* @throws \OCP\Files\NotFoundException
487487
*/
488-
public static function getStorageInfo($path, $rootInfo = null) {
488+
public static function getStorageInfo($path, $rootInfo = null, $includeMountPoints = true) {
489489
// return storage info without adding mount points
490490
$includeExtStorage = \OC::$server->getSystemConfig()->getValue('quota_include_external_storage', false);
491491

@@ -495,7 +495,7 @@ public static function getStorageInfo($path, $rootInfo = null) {
495495
if (!$rootInfo instanceof \OCP\Files\FileInfo) {
496496
throw new \OCP\Files\NotFoundException();
497497
}
498-
$used = $rootInfo->getSize();
498+
$used = $rootInfo->getSize($includeMountPoints);
499499
if ($used < 0) {
500500
$used = 0;
501501
}

0 commit comments

Comments
 (0)