Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/apps/dav
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2022-04-05 16:27:59 +0300
committerRobin Appelman <robin@icewind.nl>2022-04-06 15:40:31 +0300
commit9b1abd6fac90b97527c8db9d9119979c7753cb8c (patch)
treeb9c7a459936cf099c9aa65a8fa92fcd290816e80 /apps/dav
parentef9890fb7857282f13a8c72def13475de1e1909e (diff)
save filesystem node in dav node
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'apps/dav')
-rw-r--r--apps/dav/lib/Connector/Sabre/Directory.php9
-rw-r--r--apps/dav/lib/Connector/Sabre/File.php4
-rw-r--r--apps/dav/lib/Connector/Sabre/Node.php21
3 files changed, 33 insertions, 1 deletions
diff --git a/apps/dav/lib/Connector/Sabre/Directory.php b/apps/dav/lib/Connector/Sabre/Directory.php
index bd92b3b22a4..54ee14fdaf3 100644
--- a/apps/dav/lib/Connector/Sabre/Directory.php
+++ b/apps/dav/lib/Connector/Sabre/Directory.php
@@ -38,6 +38,7 @@ use OCA\DAV\Connector\Sabre\Exception\FileLocked;
use OCA\DAV\Connector\Sabre\Exception\Forbidden;
use OCA\DAV\Connector\Sabre\Exception\InvalidPath;
use OCP\Files\FileInfo;
+use OCP\Files\Folder;
use OCP\Files\ForbiddenException;
use OCP\Files\InvalidPathException;
use OCP\Files\NotPermittedException;
@@ -144,7 +145,9 @@ class Directory extends \OCA\DAV\Connector\Sabre\Node implements \Sabre\DAV\ICol
$info = $this->fileView->getFileInfo($this->path . '/' . $name);
if (!$info) {
// use a dummy FileInfo which is acceptable here since it will be refreshed after the put is complete
- $info = new \OC\Files\FileInfo($path, null, null, [], null);
+ $info = new \OC\Files\FileInfo($path, null, null, [
+ 'type' => FileInfo::TYPE_FILE
+ ], null);
}
$node = new \OCA\DAV\Connector\Sabre\File($this->fileView, $info);
@@ -474,4 +477,8 @@ class Directory extends \OCA\DAV\Connector\Sabre\Node implements \Sabre\DAV\ICol
return false;
}
+
+ public function getNode(): Folder {
+ return $this->node;
+ }
}
diff --git a/apps/dav/lib/Connector/Sabre/File.php b/apps/dav/lib/Connector/Sabre/File.php
index 70dffbaaaed..a46ca372be7 100644
--- a/apps/dav/lib/Connector/Sabre/File.php
+++ b/apps/dav/lib/Connector/Sabre/File.php
@@ -753,4 +753,8 @@ class File extends Node implements IFile {
public function hash(string $type) {
return $this->fileView->hash($type, $this->path);
}
+
+ public function getNode(): \OCP\Files\File {
+ return $this->node;
+ }
}
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);
}