diff options
author | skjnldsv <skjnldsv@protonmail.com> | 2024-08-16 10:22:27 +0200 |
---|---|---|
committer | John Molakvoæ <skjnldsv@users.noreply.github.com> | 2024-08-27 10:42:25 +0200 |
commit | 49b0d4ce24ec418b251f018bfef349e58d117347 (patch) | |
tree | 84428bf6a4f75f052eba18d1accc3db35733cd1f | |
parent | ead3f66379f35e42c2d5433eeca911b61a9cd968 (diff) | |
download | nextcloud-server-jr-quota-exceeded-admin-log.tar.gz nextcloud-server-jr-quota-exceeded-admin-log.zip |
feat: enhance quota exceeded logging for adminsjr-quota-exceeded-admin-log
Signed-off-by: skjnldsv <skjnldsv@protonmail.com>
-rw-r--r-- | apps/dav/lib/Connector/Sabre/QuotaPlugin.php | 14 | ||||
-rw-r--r-- | apps/dav/tests/unit/Connector/Sabre/QuotaPluginTest.php | 5 |
2 files changed, 19 insertions, 0 deletions
diff --git a/apps/dav/lib/Connector/Sabre/QuotaPlugin.php b/apps/dav/lib/Connector/Sabre/QuotaPlugin.php index deaa4cf672b..f54858dbd10 100644 --- a/apps/dav/lib/Connector/Sabre/QuotaPlugin.php +++ b/apps/dav/lib/Connector/Sabre/QuotaPlugin.php @@ -190,8 +190,22 @@ class QuotaPlugin extends \Sabre\DAV\ServerPlugin { // 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"); } } diff --git a/apps/dav/tests/unit/Connector/Sabre/QuotaPluginTest.php b/apps/dav/tests/unit/Connector/Sabre/QuotaPluginTest.php index 815837799fd..9eede1f70a8 100644 --- a/apps/dav/tests/unit/Connector/Sabre/QuotaPluginTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/QuotaPluginTest.php @@ -12,6 +12,11 @@ use OCA\DAV\Connector\Sabre\QuotaPlugin; 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; |