aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/private/Files/Node/Node.php11
-rw-r--r--tests/lib/Files/Node/NodeTest.php3
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]