diff options
author | Julius Härtl <jus@bitgrid.net> | 2023-09-06 20:09:50 +0200 |
---|---|---|
committer | Julius Härtl <jus@bitgrid.net> | 2023-09-13 10:28:28 +0200 |
commit | 7f958e81d3ead0c2c04303896e29ccc6bfbba3da (patch) | |
tree | b372ae3143eb4e26d02960c1eb05e9e04bb59bed | |
parent | c6e6ebb9992882ad2a2bcd49252bffe2248103c4 (diff) | |
download | nextcloud-server-7f958e81d3ead0c2c04303896e29ccc6bfbba3da.tar.gz nextcloud-server-7f958e81d3ead0c2c04303896e29ccc6bfbba3da.zip |
fix: Pass parent to NonExistingFile instances
Signed-off-by: Julius Härtl <jus@bitgrid.net>
-rw-r--r-- | lib/private/Files/Node/Node.php | 11 | ||||
-rw-r--r-- | tests/lib/Files/Node/NodeTest.php | 3 |
2 files changed, 11 insertions, 3 deletions
diff --git a/lib/private/Files/Node/Node.php b/lib/private/Files/Node/Node.php index 4b916bd9c1b..9729f79aae3 100644 --- a/lib/private/Files/Node/Node.php +++ b/lib/private/Files/Node/Node.php @@ -297,10 +297,19 @@ class Node implements INode { return $this->root; } + // Manually fetch the parent if the current node doesn't have a file info yet + try { + $fileInfo = $this->getFileInfo(); + } catch (NotFoundException) { + $this->parent = $this->root->get($newPath); + /** @var \OCP\Files\Folder $this->parent */ + return $this->parent; + } + // gather the metadata we already know about our parent $parentData = [ 'path' => $newPath, - 'fileid' => $this->getFileInfo()->getParentId(), + 'fileid' => $fileInfo->getParentId(), ]; // and create lazy folder with it instead of always querying diff --git a/tests/lib/Files/Node/NodeTest.php b/tests/lib/Files/Node/NodeTest.php index b63d287a191..4f782f28a36 100644 --- a/tests/lib/Files/Node/NodeTest.php +++ b/tests/lib/Files/Node/NodeTest.php @@ -481,8 +481,7 @@ abstract class NodeTest extends \Test\TestCase { $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)) - ->method('get') + $this->root->method('get') ->willReturnMap([ ['/bar/asd', $newNode], ['/bar', $parentNode] |