Skip to content

Commit 82e6de7

Browse files
committed
fixup: avoid too many queries when recursing upwards
Signed-off-by: Salvatore Martire <[email protected]>
1 parent 30acd27 commit 82e6de7

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

apps/dav/lib/Connector/Sabre/Directory.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
use OCP\Files\Folder;
2222
use OCP\Files\ForbiddenException;
2323
use OCP\Files\InvalidPathException;
24+
use OCP\Files\IRootFolder;
2425
use OCP\Files\Mount\IMountManager;
2526
use OCP\Files\NotFoundException;
2627
use OCP\Files\NotPermittedException;
@@ -556,15 +557,14 @@ public function getNodeForPath($path): INode {
556557

557558
// recurse upwards until the root (for backwards-compatibility)
558559
if ($destinationDir !== '') {
559-
$scanNode = $node->getNode()->getParent();
560-
$scanPath = basename($destinationDir);
561-
while ($parent = $scanNode->getParent()) {
562-
$parent->get($scanPath);
563-
$scanPath = $parent->getName();
564-
if ($scanPath === '') {
565-
break;
560+
$scanPath = $destinationPath;
561+
while (($scanPath = dirname($scanPath)) !== '/') {
562+
$info = $this->fileView->getFileInfo($scanPath, false);
563+
$directory = new Directory($this->fileView, $info, $this->tree, $this->shareManager);
564+
$readable = $directory->getNode()->isReadable();
565+
if (!$readable) {
566+
throw new Forbidden('No read permissions. This might be caused by files_accesscontrol, check your configured rules');
566567
}
567-
$scanNode = $parent;
568568
}
569569
}
570570

0 commit comments

Comments
 (0)