From 83b1415906babd3ad521055dd2142fed09250ca6 Mon Sep 17 00:00:00 2001 From: Julius Härtl Date: Wed, 24 Aug 2022 18:01:10 +0200 Subject: Only pass parent if paths match MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit As the user folder might be initialized by the root from two levels down the hierarchy, passing this as a parent only works if the path matches Signed-off-by: Julius Härtl --- lib/private/Files/Node/Folder.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'lib/private/Files') diff --git a/lib/private/Files/Node/Folder.php b/lib/private/Files/Node/Folder.php index 868906c82d1..81ca7e254d9 100644 --- a/lib/private/Files/Node/Folder.php +++ b/lib/private/Files/Node/Folder.php @@ -119,10 +119,11 @@ class Folder extends Node implements \OCP\Files\Folder { } else { $isDir = $info->getType() === FileInfo::TYPE_FOLDER; } + $parent = dirname($path) === $this->getPath() ? $this : null; if ($isDir) { - return new Folder($this->root, $this->view, $path, $info); + return new Folder($this->root, $this->view, $path, $info, $parent); } else { - return new File($this->root, $this->view, $path, $info); + return new File($this->root, $this->view, $path, $info, $parent); } } @@ -163,7 +164,8 @@ class Folder extends Node implements \OCP\Files\Folder { if (!$this->view->mkdir($fullPath)) { throw new NotPermittedException('Could not create folder'); } - $node = new Folder($this->root, $this->view, $fullPath, null, $this); + $parent = dirname($fullPath) === $this->getPath() ? $this : null; + $node = new Folder($this->root, $this->view, $fullPath, null, $parent); $this->sendHooks(['postWrite', 'postCreate'], [$node]); return $node; } else { -- cgit v1.2.3