Skip to content

Commit b8b53a2

Browse files
authored
Merge pull request #19436 from nextcloud/bugfix/noid/dav-quota-calculation
Do not include mountpoints when calculating quota usage on WebDAV
2 parents a1f3293 + 902d125 commit b8b53a2

2 files changed

Lines changed: 20 additions & 11 deletions

File tree

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,8 @@ public function getQuotaInfo() {
326326
return $this->quotaInfo;
327327
}
328328
try {
329-
$storageInfo = \OC_Helper::getStorageInfo($this->info->getPath(), $this->info);
329+
$info = $this->fileView->getFileInfo($this->path, false);
330+
$storageInfo = \OC_Helper::getStorageInfo($this->info->getPath(), $info);
330331
if ($storageInfo['quota'] === \OCP\Files\FileInfo::SPACE_UNLIMITED) {
331332
$free = \OCP\Files\FileInfo::SPACE_UNLIMITED;
332333
} else {

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

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ private function getDir($path = '/') {
9898
return new Directory($this->view, $this->info);
9999
}
100100

101-
101+
102102
public function testDeleteRootFolderFails() {
103103
$this->expectException(\Sabre\DAV\Exception\Forbidden::class);
104104

@@ -111,7 +111,7 @@ public function testDeleteRootFolderFails() {
111111
$dir->delete();
112112
}
113113

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

@@ -130,7 +130,7 @@ public function testDeleteForbidden() {
130130
$dir->delete();
131131
}
132132

133-
133+
134134
public function testDeleteFolderWhenAllowed() {
135135
// deletion allowed
136136
$this->info->expects($this->once())
@@ -147,7 +147,7 @@ public function testDeleteFolderWhenAllowed() {
147147
$dir->delete();
148148
}
149149

150-
150+
151151
public function testDeleteFolderFailsWhenNotAllowed() {
152152
$this->expectException(\Sabre\DAV\Exception\Forbidden::class);
153153

@@ -159,7 +159,7 @@ public function testDeleteFolderFailsWhenNotAllowed() {
159159
$dir->delete();
160160
}
161161

162-
162+
163163
public function testDeleteFolderThrowsWhenDeletionFailed() {
164164
$this->expectException(\Sabre\DAV\Exception\Forbidden::class);
165165

@@ -217,7 +217,7 @@ public function testGetChildren() {
217217
$dir->getChildren();
218218
}
219219

220-
220+
221221
public function testGetChildrenNoPermission() {
222222
$this->expectException(\Sabre\DAV\Exception\Forbidden::class);
223223

@@ -230,7 +230,7 @@ public function testGetChildrenNoPermission() {
230230
$dir->getChildren();
231231
}
232232

233-
233+
234234
public function testGetChildNoPermission() {
235235
$this->expectException(\Sabre\DAV\Exception\NotFound::class);
236236

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

245-
245+
246246
public function testGetChildThrowStorageNotAvailableException() {
247247
$this->expectException(\Sabre\DAV\Exception\ServiceUnavailable::class);
248248

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

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

@@ -295,6 +295,10 @@ public function testGetQuotaInfoUnlimited() {
295295
->method('getStorage')
296296
->willReturn($storage);
297297

298+
$this->view->expects($this->once())
299+
->method('getFileInfo')
300+
->willReturn($this->info);
301+
298302
$dir = new Directory($this->view, $this->info);
299303
$this->assertEquals([200, -3], $dir->getQuotaInfo()); //200 used, unlimited
300304
}
@@ -327,6 +331,10 @@ public function testGetQuotaInfoSpecific() {
327331
->method('getStorage')
328332
->willReturn($storage);
329333

334+
$this->view->expects($this->once())
335+
->method('getFileInfo')
336+
->willReturn($this->info);
337+
330338
$dir = new Directory($this->view, $this->info);
331339
$this->assertEquals([200, 800], $dir->getQuotaInfo()); //200 used, 800 free
332340
}
@@ -404,7 +412,7 @@ private function moveTest($source, $destination, $updatables, $deletables) {
404412
$this->assertTrue($targetNode->moveInto(basename($destination), $source, $sourceNode));
405413
}
406414

407-
415+
408416
public function testFailingMove() {
409417
$this->expectException(\Sabre\DAV\Exception\Forbidden::class);
410418
$this->expectExceptionMessage('Could not copy directory b, target exists');

0 commit comments

Comments
 (0)