fix: Pass parent to NonExistingFile instances

Signed-off-by: Julius Härtl <jus@bitgrid.net>
pull/40312/head
Julius Härtl 1 year ago
parent c6e6ebb999
commit 7f958e81d3
No known key found for this signature in database
GPG Key ID: 4C614C6ED2CDE6DF
  1. 11
      lib/private/Files/Node/Node.php
  2. 3
      tests/lib/Files/Node/NodeTest.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

@ -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]

Loading…
Cancel
Save