Merge pull request #49991 from nextcloud/backport/49887/stable30

This commit is contained in:
Kate 2025-01-20 17:28:02 +01:00 committed by GitHub
commit 1c99b367be
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 9 additions and 10 deletions

View file

@ -2258,14 +2258,6 @@
<code><![CDATA[int]]></code>
</InvalidReturnType>
</file>
<file src="lib/private/Files/Utils/Scanner.php">
<LessSpecificReturnStatement>
<code><![CDATA[$mounts]]></code>
</LessSpecificReturnStatement>
<MoreSpecificReturnType>
<code><![CDATA[\OC\Files\Mount\MountPoint[]]]></code>
</MoreSpecificReturnType>
</file>
<file src="lib/private/Files/View.php">
<InvalidScalarArgument>
<code><![CDATA[$mtime]]></code>

View file

@ -23,6 +23,7 @@ use OCP\Files\Events\FileScannedEvent;
use OCP\Files\Events\FolderScannedEvent;
use OCP\Files\Events\NodeAddedToCache;
use OCP\Files\Events\NodeRemovedFromCache;
use OCP\Files\Mount\IMountPoint;
use OCP\Files\NotFoundException;
use OCP\Files\Storage\IStorage;
use OCP\Files\StorageNotAvailableException;
@ -85,7 +86,7 @@ class Scanner extends PublicEmitter {
* get all storages for $dir
*
* @param string $dir
* @return \OC\Files\Mount\MountPoint[]
* @return array<string, IMountPoint>
*/
protected function getMounts($dir) {
//TODO: move to the node based fileapi once that's done
@ -96,8 +97,9 @@ class Scanner extends PublicEmitter {
$mounts = $mountManager->findIn($dir);
$mounts[] = $mountManager->find($dir);
$mounts = array_reverse($mounts); //start with the mount of $dir
$mountPoints = array_map(fn ($mount) => $mount->getMountPoint(), $mounts);
return $mounts;
return array_combine($mountPoints, $mounts);
}
/**
@ -145,6 +147,7 @@ class Scanner extends PublicEmitter {
continue;
}
/** @var \OC\Files\Cache\Scanner $scanner */
$scanner = $storage->getScanner();
$this->attachListener($mount);
@ -208,6 +211,9 @@ class Scanner extends PublicEmitter {
$owner = $owner['name'] ?? $ownerUid;
$permissions = decoct(fileperms($fullPath));
throw new ForbiddenException("User folder $fullPath is not writable, folders is owned by $owner and has mode $permissions");
} elseif (isset($mounts[$mount->getMountPoint() . $path . '/'])) {
// /<user>/files is overwritten by a mountpoint, so this check is irrelevant
break;
} else {
// if the root exists in neither the cache nor the storage the user isn't setup yet
break 2;
@ -221,6 +227,7 @@ class Scanner extends PublicEmitter {
continue;
}
$relativePath = $mount->getInternalPath($dir);
/** @var \OC\Files\Cache\Scanner $scanner */
$scanner = $storage->getScanner();
$scanner->setUseTransactions(false);
$this->attachListener($mount);