summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorJulius Härtl <jus@bitgrid.net>2023-02-18 15:41:01 +0100
committerJulius Härtl (Rebase PR Action) <github@juliushaertl.de>2023-03-06 22:46:07 +0000
commitd515da502f34af151e156ba383c1d2e5c8289520 (patch)
treeec10b1749ed0b4018bf8917f96c0abf54ca88ec7 /apps
parent3287eddbbc4465ee5fcb39016b3ad0ad27959ea6 (diff)
downloadnextcloud-server-d515da502f34af151e156ba383c1d2e5c8289520.tar.gz
nextcloud-server-d515da502f34af151e156ba383c1d2e5c8289520.zip
fix: Use proper path for quota fetching
Signed-off-by: Julius Härtl <jus@bitgrid.net>
Diffstat (limited to 'apps')
-rw-r--r--apps/dav/lib/Connector/Sabre/Directory.php8
-rw-r--r--apps/dav/tests/unit/Connector/Sabre/DirectoryTest.php12
2 files changed, 19 insertions, 1 deletions
diff --git a/apps/dav/lib/Connector/Sabre/Directory.php b/apps/dav/lib/Connector/Sabre/Directory.php
index 396cfc3417c..531ccff9d92 100644
--- a/apps/dav/lib/Connector/Sabre/Directory.php
+++ b/apps/dav/lib/Connector/Sabre/Directory.php
@@ -325,8 +325,14 @@ class Directory extends \OCA\DAV\Connector\Sabre\Node implements \Sabre\DAV\ICol
if ($this->quotaInfo) {
return $this->quotaInfo;
}
+ $relativePath = $this->fileView->getRelativePath($this->info->getPath());
+ if ($relativePath === null) {
+ $logger->warning("error while getting quota as the relative path cannot be found");
+ return [0, 0];
+ }
+
try {
- $storageInfo = \OC_Helper::getStorageInfo($this->info->getPath(), $this->info, false);
+ $storageInfo = \OC_Helper::getStorageInfo($relativePath, $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 edbe4278c3a..a74cb139966 100644
--- a/apps/dav/tests/unit/Connector/Sabre/DirectoryTest.php
+++ b/apps/dav/tests/unit/Connector/Sabre/DirectoryTest.php
@@ -304,6 +304,10 @@ class DirectoryTest extends \Test\TestCase {
->method('free_space')
->willReturn(800);
+ $this->info->expects($this->any())
+ ->method('getPath')
+ ->willReturn('/admin/files/foo');
+
$this->info->expects($this->once())
->method('getSize')
->willReturn(200);
@@ -312,6 +316,10 @@ class DirectoryTest extends \Test\TestCase {
->method('getMountPoint')
->willReturn($mountPoint);
+ $this->view->expects($this->any())
+ ->method('getRelativePath')
+ ->willReturn('/foo');
+
$mountPoint->method('getMountPoint')
->willReturn('/user/files/mymountpoint');
@@ -359,6 +367,10 @@ class DirectoryTest extends \Test\TestCase {
$mountPoint->method('getMountPoint')
->willReturn('/user/files/mymountpoint');
+ $this->view->expects($this->any())
+ ->method('getRelativePath')
+ ->willReturn('/foo');
+
$dir = new Directory($this->view, $this->info);
$this->assertEquals([200, 800], $dir->getQuotaInfo()); //200 used, 800 free
}