Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
feat: enhance quota exceeded logging for admins
Signed-off-by: skjnldsv <[email protected]>
  • Loading branch information
skjnldsv committed Aug 27, 2024
commit 49b0d4ce24ec418b251f018bfef349e58d117347
14 changes: 14 additions & 0 deletions apps/dav/lib/Connector/Sabre/QuotaPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,22 @@ public function checkQuota(string $path, $length = null) {
// 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");
}
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 @@ -12,6 +12,11 @@
use OCP\Files\FileInfo;
use Test\TestCase;

/**
* Class QuotaPluginTest
*
* @group DB
*/
class QuotaPluginTest extends TestCase {
/** @var \Sabre\DAV\Server | \PHPUnit\Framework\MockObject\MockObject */
private $server;
Expand Down