1
0
Mirror von https://github.com/nextcloud/server.git synchronisiert 2024-08-04 20:17:16 +02:00

save filesystem node in dav node

Signed-off-by: Robin Appelman <robin@icewind.nl>
Dieser Commit ist enthalten in:
Robin Appelman 2022-04-05 15:27:59 +02:00
Ursprung ef9890fb78
Commit 9b1abd6fac
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 42B69D8A64526EFB
4 geänderte Dateien mit 34 neuen und 2 gelöschten Zeilen

Datei anzeigen

@ -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;
}
}

Datei anzeigen

@ -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;
}
}

Datei anzeigen

@ -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);
}

Datei anzeigen

@ -254,7 +254,7 @@ class FileInfo implements \OCP\Files\FileInfo, \ArrayAccess {
*/
public function getType() {
if (!isset($this->data['type'])) {
$this->data['type'] = ($this->getMimetype() === 'httpd/unix-directory') ? self::TYPE_FOLDER : self::TYPE_FILE;
$this->data['type'] = ($this->getMimetype() === self::MIMETYPE_FOLDER) ? self::TYPE_FOLDER : self::TYPE_FILE;
}
return $this->data['type'];
}