Skip to content
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
Enhance quota exceeded logging for admins
* Adds owner of target folder (i.e. when shared)
* Only log owner if not current user
* Clarifies user quota vs disk space issue
* Special $path handling for non-Chunked-v2 uploads
* Mimic current path behavior for targets that already exist
* Add db access to unit tests

Addresses backend portion of #37519

Signed-off-by: Josh Richards <[email protected]>
  • Loading branch information
joshtrichards authored and szaimen committed Jul 18, 2023
commit d1fb2c6b215e0c5cc2d322561ebf87cbe49b8c81
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");
} 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