aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEdward Ly <contact@edward.ly>2025-03-20 08:53:38 -0700
committerEdward Ly <contact@edward.ly>2025-03-20 11:43:40 -0700
commiteee8b309e651c8647614429cc5f99ddd914a2397 (patch)
treed23fbab95a01e9fff4d8f71720fad22be8728ee0
parent569b21fdfe659af70aa7f9c23e8def2f96a20c3c (diff)
downloadnextcloud-server-fix/quota-exceptions.tar.gz
nextcloud-server-fix/quota-exceptions.zip
fix(Quota): throw NotEnoughSpaceException if file quota exceeded for mkdir operationfix/quota-exceptions
Signed-off-by: Edward Ly <contact@edward.ly>
-rw-r--r--lib/private/Files/Storage/Wrapper/Quota.php3
-rw-r--r--tests/lib/Files/Storage/Wrapper/QuotaTest.php4
2 files changed, 5 insertions, 2 deletions
diff --git a/lib/private/Files/Storage/Wrapper/Quota.php b/lib/private/Files/Storage/Wrapper/Quota.php
index 3be77ba1b37..d90d84d53f3 100644
--- a/lib/private/Files/Storage/Wrapper/Quota.php
+++ b/lib/private/Files/Storage/Wrapper/Quota.php
@@ -11,6 +11,7 @@ use OC\Files\Filesystem;
use OC\SystemConfig;
use OCP\Files\Cache\ICacheEntry;
use OCP\Files\FileInfo;
+use OCP\Files\NotEnoughSpaceException;
use OCP\Files\Storage\IStorage;
class Quota extends Wrapper {
@@ -180,7 +181,7 @@ class Quota extends Wrapper {
}
$free = $this->free_space($path);
if ($this->shouldApplyQuota($path) && $free == 0) {
- return false;
+ throw new NotEnoughSpaceException('Unable to create directory (' . $path . '): not enough free space');
}
return parent::mkdir($path);
diff --git a/tests/lib/Files/Storage/Wrapper/QuotaTest.php b/tests/lib/Files/Storage/Wrapper/QuotaTest.php
index f07e6021e4e..22703785c47 100644
--- a/tests/lib/Files/Storage/Wrapper/QuotaTest.php
+++ b/tests/lib/Files/Storage/Wrapper/QuotaTest.php
@@ -10,6 +10,7 @@ namespace Test\Files\Storage\Wrapper;
//ensure the constants are loaded
use OC\Files\Cache\CacheEntry;
use OC\Files\Storage\Local;
+use OCP\Files\NotEnoughSpaceException;
\OC::$loader->load('\OC\Files\Filesystem');
@@ -211,7 +212,8 @@ class QuotaTest extends \Test\Files\Storage\Storage {
public function testNoMkdirQuotaZero(): void {
$instance = $this->getLimitedStorage(0.0);
$this->assertFalse($instance->mkdir('files'));
- $this->assertFalse($instance->mkdir('files/foobar'));
+ $this->expectException(NotEnoughSpaceException::class);
+ $instance->mkdir('files/foobar');
}
public function testMkdirQuotaZeroTrashbin(): void {