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

Do not include mountpoints when calculating quota usage on WebDAV #19436

Merged
merged 1 commit into from
Apr 30, 2020
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: 2 additions & 1 deletion apps/dav/lib/Connector/Sabre/Directory.php
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,8 @@ public function getQuotaInfo() {
return $this->quotaInfo;
}
try {
$storageInfo = \OC_Helper::getStorageInfo($this->info->getPath(), $this->info);
$info = $this->fileView->getFileInfo($this->path, false);
$storageInfo = \OC_Helper::getStorageInfo($this->info->getPath(), $info);
if ($storageInfo['quota'] === \OCP\Files\FileInfo::SPACE_UNLIMITED) {
$free = \OCP\Files\FileInfo::SPACE_UNLIMITED;
} else {
Expand Down
28 changes: 18 additions & 10 deletions apps/dav/tests/unit/Connector/Sabre/DirectoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ private function getDir($path = '/') {
return new Directory($this->view, $this->info);
}


public function testDeleteRootFolderFails() {
$this->expectException(\Sabre\DAV\Exception\Forbidden::class);

Expand All @@ -111,7 +111,7 @@ public function testDeleteRootFolderFails() {
$dir->delete();
}


public function testDeleteForbidden() {
$this->expectException(\OCA\DAV\Connector\Sabre\Exception\Forbidden::class);

Expand All @@ -130,7 +130,7 @@ public function testDeleteForbidden() {
$dir->delete();
}


public function testDeleteFolderWhenAllowed() {
// deletion allowed
$this->info->expects($this->once())
Expand All @@ -147,7 +147,7 @@ public function testDeleteFolderWhenAllowed() {
$dir->delete();
}


public function testDeleteFolderFailsWhenNotAllowed() {
$this->expectException(\Sabre\DAV\Exception\Forbidden::class);

Expand All @@ -159,7 +159,7 @@ public function testDeleteFolderFailsWhenNotAllowed() {
$dir->delete();
}


public function testDeleteFolderThrowsWhenDeletionFailed() {
$this->expectException(\Sabre\DAV\Exception\Forbidden::class);

Expand Down Expand Up @@ -217,7 +217,7 @@ public function testGetChildren() {
$dir->getChildren();
}


public function testGetChildrenNoPermission() {
$this->expectException(\Sabre\DAV\Exception\Forbidden::class);

Expand All @@ -230,7 +230,7 @@ public function testGetChildrenNoPermission() {
$dir->getChildren();
}


public function testGetChildNoPermission() {
$this->expectException(\Sabre\DAV\Exception\NotFound::class);

Expand All @@ -242,7 +242,7 @@ public function testGetChildNoPermission() {
$dir->getChild('test');
}


public function testGetChildThrowStorageNotAvailableException() {
$this->expectException(\Sabre\DAV\Exception\ServiceUnavailable::class);

Expand All @@ -254,7 +254,7 @@ public function testGetChildThrowStorageNotAvailableException() {
$dir->getChild('.');
}


public function testGetChildThrowInvalidPath() {
$this->expectException(\OCA\DAV\Connector\Sabre\Exception\InvalidPath::class);

Expand Down Expand Up @@ -295,6 +295,10 @@ public function testGetQuotaInfoUnlimited() {
->method('getStorage')
->willReturn($storage);

$this->view->expects($this->once())
->method('getFileInfo')
->willReturn($this->info);

$dir = new Directory($this->view, $this->info);
$this->assertEquals([200, -3], $dir->getQuotaInfo()); //200 used, unlimited
}
Expand Down Expand Up @@ -327,6 +331,10 @@ public function testGetQuotaInfoSpecific() {
->method('getStorage')
->willReturn($storage);

$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 Expand Up @@ -404,7 +412,7 @@ private function moveTest($source, $destination, $updatables, $deletables) {
$this->assertTrue($targetNode->moveInto(basename($destination), $source, $sourceNode));
}


public function testFailingMove() {
$this->expectException(\Sabre\DAV\Exception\Forbidden::class);
$this->expectExceptionMessage('Could not copy directory b, target exists');
Expand Down