Quellcode durchsuchen

save filesystem node in dav node

Signed-off-by: Robin Appelman <robin@icewind.nl>
tags/v24.0.0beta3
Robin Appelman vor 2 Jahren
Ursprung
Commit
9b1abd6fac
Es ist kein Account mit der E-Mail-Adresse des Committers verbunden

+ 8
- 1
apps/dav/lib/Connector/Sabre/Directory.php 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;
}
}

+ 4
- 0
apps/dav/lib/Connector/Sabre/File.php 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;
}
}

+ 21
- 0
apps/dav/lib/Connector/Sabre/Node.php 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);
}

+ 1
- 1
lib/private/Files/FileInfo.php 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'];
}

Laden…
Abbrechen
Speichern