Skip to content
Draft
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
15 changes: 14 additions & 1 deletion apps/dav/lib/Connector/Sabre/QuotaPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -217,12 +217,25 @@ public function checkQuota(string $path, $length = null, $isDir = false) {
// Strip any duplicate slashes
$path = str_replace('//', '/', $path);

// TODO: I suspect the below existence check more properly belongs in
// beforeCreateFile(), similar to what already exists in
// beforeCopy and beforeMove()
// NOTE: && or || here is equivalent in terms of outcome (but && our intention)
// because only other times the full path SHOULD get to us here is when
// existence has already been confirmed - see beforeCopy() & beforeMove())
if (($req->getHeader('Destination') === null || $req->getHeader('Destination') === '') && !$this->server->tree->nodeExists($path)) {
$path = dirname($path);
}

$targetOwner = $this->view->getOwner($path);
$freeSpace = $this->getFreeSpace($path);
if ($freeSpace >= 0 && $length > $freeSpace) {
if ($targetOwner !== \OC_User::getUser()) {
throw new InsufficientStorage("Quota exceeded in $path (owner: $targetOwner), $length required, $freeSpace available");
}
if ($isDir) {
throw new InsufficientStorage("Insufficient space in $path. $freeSpace available. Cannot create directory");
}

throw new InsufficientStorage("Insufficient space in $path, $length required, $freeSpace available");
}
}
Expand Down
5 changes: 5 additions & 0 deletions apps/dav/tests/unit/Connector/Sabre/QuotaPluginTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@
use OCP\Files\FileInfo;
use Test\TestCase;

/**
* Class QuotaPluginTest
*
* @group DB
*/
class QuotaPluginTest extends TestCase {
private \Sabre\DAV\Server $server;

Expand Down
Loading