Skip to content

Commit 76260ff

Browse files
Merge pull request #52769 from nextcloud/backport/52665/stable31
[stable31] fix: create mountpoint folder even if the user has a quota of 0
2 parents 61182a1 + 54338f6 commit 76260ff

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

lib/private/Files/Storage/Wrapper/Quota.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ class Quota extends Wrapper {
2121
protected string $sizeRoot;
2222
private SystemConfig $config;
2323
private bool $quotaIncludeExternalStorage;
24+
private bool $enabled = true;
2425

2526
/**
2627
* @param array $parameters
@@ -46,6 +47,9 @@ public function getQuota(): int|float {
4647
}
4748

4849
private function hasQuota(): bool {
50+
if (!$this->enabled) {
51+
return false;
52+
}
4953
return $this->getQuota() !== FileInfo::SPACE_UNLIMITED;
5054
}
5155

@@ -197,4 +201,8 @@ public function touch(string $path, ?int $mtime = null): bool {
197201

198202
return parent::touch($path, $mtime);
199203
}
204+
205+
public function enableQuota(bool $enabled): void {
206+
$this->enabled = $enabled;
207+
}
200208
}

lib/private/Files/View.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Icewind\Streams\CallbackWrapper;
1111
use OC\Files\Mount\MoveableMount;
1212
use OC\Files\Storage\Storage;
13+
use OC\Files\Storage\Wrapper\Quota;
1314
use OC\Share\Share;
1415
use OC\User\LazyUser;
1516
use OC\User\Manager as UserManager;
@@ -1579,12 +1580,22 @@ public function getDirectoryContent($directory, $mimetype_filter = '', ?\OCP\Fil
15791580
// Create parent folders if the mountpoint is inside a subfolder that doesn't exist yet
15801581
if (!isset($files[$entryName])) {
15811582
try {
1583+
[$storage, ] = $this->resolvePath($path . '/' . $entryName);
1584+
// make sure we can create the mountpoint folder, even if the user has a quota of 0
1585+
if ($storage->instanceOfStorage(Quota::class)) {
1586+
$storage->enableQuota(false);
1587+
}
1588+
15821589
if ($this->mkdir($path . '/' . $entryName) !== false) {
15831590
$info = $this->getFileInfo($path . '/' . $entryName);
15841591
if ($info !== false) {
15851592
$files[$entryName] = $info;
15861593
}
15871594
}
1595+
1596+
if ($storage->instanceOfStorage(Quota::class)) {
1597+
$storage->enableQuota(true);
1598+
}
15881599
} catch (\Exception $e) {
15891600
// Creating the parent folder might not be possible, for example due to a lack of permissions.
15901601
$this->logger->debug('Failed to create non-existent parent', ['exception' => $e, 'path' => $path . '/' . $entryName]);

0 commit comments

Comments
 (0)