From 0dfddfc492398aede5ffa7281626005a08aa2cb6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20H=C3=A4rtl?= Date: Wed, 6 Sep 2023 20:09:50 +0200 Subject: [PATCH] fix: Pass parent to NonExistingFile instances MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Härtl --- lib/private/Files/Node/File.php | 2 +- lib/private/Files/Node/HookConnector.php | 4 ++-- tests/lib/Files/Node/NodeTest.php | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/private/Files/Node/File.php b/lib/private/Files/Node/File.php index b6cd65716510b..18afd2b8f3853 100644 --- a/lib/private/Files/Node/File.php +++ b/lib/private/Files/Node/File.php @@ -40,7 +40,7 @@ class File extends Node implements \OCP\Files\File { * @return NonExistingFile non-existing node */ protected function createNonExistingNode($path) { - return new NonExistingFile($this->root, $this->view, $path); + return new NonExistingFile($this->root, $this->view, $path, $this->root->get(dirname($path))); } /** diff --git a/lib/private/Files/Node/HookConnector.php b/lib/private/Files/Node/HookConnector.php index a8e76d95c22c4..c33c670a42f56 100644 --- a/lib/private/Files/Node/HookConnector.php +++ b/lib/private/Files/Node/HookConnector.php @@ -224,9 +224,9 @@ private function getNodeForPath(string $path): Node { $info = null; } if (Filesystem::is_dir($path)) { - return new NonExistingFolder($this->root, $this->view, $fullPath, $info); + return new NonExistingFolder($this->root, $this->view, $fullPath, $info, $this->root->get(dirname($fullPath))); } else { - return new NonExistingFile($this->root, $this->view, $fullPath, $info); + return new NonExistingFile($this->root, $this->view, $fullPath, $info, $this->root->get(dirname($fullPath))); } } if ($info->getType() === FileInfo::TYPE_FILE) { diff --git a/tests/lib/Files/Node/NodeTest.php b/tests/lib/Files/Node/NodeTest.php index b63d287a1913f..6087c5d03eb1c 100644 --- a/tests/lib/Files/Node/NodeTest.php +++ b/tests/lib/Files/Node/NodeTest.php @@ -481,7 +481,7 @@ public function testCopySameStorage() { $parentNode = new \OC\Files\Node\Folder($this->root, $this->view, '/bar'); $newNode = $this->createTestNode($this->root, $this->view, '/bar/asd'); - $this->root->expects($this->exactly(2)) + $this->root->expects($this->any()) ->method('get') ->willReturnMap([ ['/bar/asd', $newNode],