From 9b1abd6fac90b97527c8db9d9119979c7753cb8c Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Tue, 5 Apr 2022 15:27:59 +0200 Subject: save filesystem node in dav node Signed-off-by: Robin Appelman --- apps/dav/lib/Connector/Sabre/Node.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'apps/dav/lib/Connector/Sabre/Node.php') diff --git a/apps/dav/lib/Connector/Sabre/Node.php b/apps/dav/lib/Connector/Sabre/Node.php index 79b4db0e327..79f1653c692 100644 --- a/apps/dav/lib/Connector/Sabre/Node.php +++ b/apps/dav/lib/Connector/Sabre/Node.php @@ -36,9 +36,12 @@ namespace OCA\DAV\Connector\Sabre; use OC\Files\Mount\MoveableMount; +use OC\Files\Node\File; +use OC\Files\Node\Folder; use OC\Files\View; use OCA\DAV\Connector\Sabre\Exception\InvalidPath; use OCP\Files\FileInfo; +use OCP\Files\IRootFolder; use OCP\Files\StorageNotAvailableException; use OCP\Share\IShare; use OCP\Share\Exceptions\ShareNotFound; @@ -75,6 +78,8 @@ abstract class Node implements \Sabre\DAV\INode { */ protected $shareManager; + protected \OC\Files\Node\Node $node; + /** * Sets up the node, expects a full path name * @@ -91,10 +96,22 @@ abstract class Node implements \Sabre\DAV\INode { } else { $this->shareManager = \OC::$server->getShareManager(); } + $root = \OC::$server->get(IRootFolder::class); + if ($info->getType()=== FileInfo::TYPE_FOLDER) { + $this->node = new Folder($root, $view, $this->path, $info); + } else { + $this->node = new File($root, $view, $this->path, $info); + } } protected function refreshInfo() { $this->info = $this->fileView->getFileInfo($this->path); + $root = \OC::$server->get(IRootFolder::class); + if ($this->info->getType() === FileInfo::TYPE_FOLDER) { + $this->node = new Folder($root, $this->fileView, $this->path, $this->info); + } else { + $this->node = new File($root, $this->fileView, $this->path, $this->info); + } } /** @@ -403,6 +420,10 @@ abstract class Node implements \Sabre\DAV\INode { return $this->info; } + public function getNode(): \OCP\Files\Node { + return $this->node; + } + protected function sanitizeMtime($mtimeFromRequest) { return MtimeSanitizer::sanitizeMtime($mtimeFromRequest); } -- cgit v1.2.3