From 0ff83f7230a0c16a3ea99390a8e23706adb497c4 Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Wed, 2 May 2018 22:05:50 +0200 Subject: [PATCH] Do not allow folder creation with quota of 0 Fixes #4577 Users with a quota of 0 are a special case. Since they can't (ever) create files on their own storage. Therefor it makes no real that they can create folders (and possible share those etc). Signed-off-by: Roeland Jago Douma --- lib/private/Files/Storage/Wrapper/Quota.php | 8 ++++++++ tests/lib/Files/Storage/Wrapper/QuotaTest.php | 5 +++++ 2 files changed, 13 insertions(+) diff --git a/lib/private/Files/Storage/Wrapper/Quota.php b/lib/private/Files/Storage/Wrapper/Quota.php index 22338f9c3c..4923dcd4d7 100644 --- a/lib/private/Files/Storage/Wrapper/Quota.php +++ b/lib/private/Files/Storage/Wrapper/Quota.php @@ -200,4 +200,12 @@ class Quota extends Wrapper { return false; } } + + public function mkdir($path) { + if ($this->quota === 0.0) { + return false; + } + + return parent::mkdir($path); + } } diff --git a/tests/lib/Files/Storage/Wrapper/QuotaTest.php b/tests/lib/Files/Storage/Wrapper/QuotaTest.php index b796e767a7..546ab69ef6 100644 --- a/tests/lib/Files/Storage/Wrapper/QuotaTest.php +++ b/tests/lib/Files/Storage/Wrapper/QuotaTest.php @@ -208,4 +208,9 @@ class QuotaTest extends \Test\Files\Storage\Storage { $this->assertTrue($this->instance->instanceOfStorage('\OC\Files\Storage\Wrapper\Wrapper')); $this->assertTrue($this->instance->instanceOfStorage('\OC\Files\Storage\Wrapper\Quota')); } + + public function testNoMkdirQuotaZero() { + $instance = $this->getLimitedStorage(0.0); + $this->assertFalse($instance->mkdir('foobar')); + } }