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

Enhance quota exceeded logging for admins #37581

Closed
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
17 changes: 16 additions & 1 deletion apps/dav/lib/Connector/Sabre/QuotaPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -202,12 +202,27 @@ public function checkQuota($path, $length = null) {
// use target file name for free space check in case of shared files
$path = rtrim($parentPath, '/') . '/' . $info['name'];
}

// 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') && !$this->server->tree->nodeExists($path)) {
$path = dirname($path);
}
$targetOwner = $this->view->getOwner($path);
$freeSpace = $this->getFreeSpace($path);
if ($freeSpace >= 0 && $length > $freeSpace) {
if (isset($chunkHandler)) {
$chunkHandler->cleanup();
}
throw new InsufficientStorage("Insufficient space in $path, $length required, $freeSpace available");
if ($targetOwner !== \OC_User::getUser()) {
throw new InsufficientStorage("Quota exceeded in $path (owner: $targetOwner), $length required, $freeSpace available");
joshtrichards marked this conversation as resolved.
Show resolved Hide resolved
} else {
throw new InsufficientStorage("Quota exceeded in $path, $length required, $freeSpace available");
}
}
}
return true;
Expand Down
8 changes: 8 additions & 0 deletions apps/dav/tests/unit/Connector/Sabre/QuotaPluginTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@
* later.
* See the COPYING-README file.
*/

/**
* Class QuotaPluginTest
*
* @group DB
*
*/

class QuotaPluginTest extends TestCase {

/** @var \Sabre\DAV\Server | \PHPUnit\Framework\MockObject\MockObject */
Expand Down