Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable23] dont re-query fileinfo when getting dav quota #31836

Merged
merged 1 commit into from
Apr 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions apps/dav/lib/Connector/Sabre/Directory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
8 changes: 0 additions & 8 deletions apps/dav/tests/unit/Connector/Sabre/DirectoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down Expand Up @@ -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
}
Expand Down
4 changes: 2 additions & 2 deletions lib/private/legacy/OC_Helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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;
}
Expand Down