aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--apps/dav/lib/Connector/Sabre/QuotaPlugin.php14
-rw-r--r--apps/dav/tests/unit/Connector/Sabre/QuotaPluginTest.php5
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;