Skip to content

Commit 0200882

Browse files
authored
Merge pull request #50470 from nextcloud/fix/49887/early-check-for-overwritten-home
2 parents 64b1428 + 809d638 commit 0200882

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

lib/private/Files/Utils/Scanner.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -205,17 +205,17 @@ public function scan($dir = '', $recursive = \OC\Files\Cache\Scanner::SCAN_RECUR
205205
foreach (['', 'files'] as $path) {
206206
if (!$storage->isCreatable($path)) {
207207
$fullPath = $storage->getSourcePath($path);
208-
if (!$storage->is_dir($path) && $storage->getCache()->inCache($path)) {
208+
if (isset($mounts[$mount->getMountPoint() . $path . '/'])) {
209+
// /<user>/files is overwritten by a mountpoint, so this check is irrelevant
210+
break;
211+
} elseif (!$storage->is_dir($path) && $storage->getCache()->inCache($path)) {
209212
throw new NotFoundException("User folder $fullPath exists in cache but not on disk");
210213
} elseif ($storage->is_dir($path)) {
211214
$ownerUid = fileowner($fullPath);
212215
$owner = posix_getpwuid($ownerUid);
213216
$owner = $owner['name'] ?? $ownerUid;
214217
$permissions = decoct(fileperms($fullPath));
215218
throw new ForbiddenException("User folder $fullPath is not writable, folders is owned by $owner and has mode $permissions");
216-
} elseif (isset($mounts[$mount->getMountPoint() . $path . '/'])) {
217-
// /<user>/files is overwritten by a mountpoint, so this check is irrelevant
218-
break;
219219
} else {
220220
// if the root exists in neither the cache nor the storage the user isn't setup yet
221221
break 2;

0 commit comments

Comments
 (0)