diff options
author | Arthur Schiwon <blizzz@arthur-schiwon.de> | 2023-06-08 23:32:16 +0200 |
---|---|---|
committer | Arthur Schiwon <blizzz@arthur-schiwon.de> | 2023-06-21 16:53:20 +0200 |
commit | f6ac874dbf7d4e5cb2255f25464df214bb956ffb (patch) | |
tree | e3bcd4a4aa85e1f35af4124d3c578080c640954b /lib/private/Files/Node | |
parent | 167a5f394d9baafaa450843f76864070412727ca (diff) | |
download | nextcloud-server-f6ac874dbf7d4e5cb2255f25464df214bb956ffb.tar.gz nextcloud-server-f6ac874dbf7d4e5cb2255f25464df214bb956ffb.zip |
chore: ugly type juggling
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Diffstat (limited to 'lib/private/Files/Node')
-rw-r--r-- | lib/private/Files/Node/Folder.php | 11 | ||||
-rw-r--r-- | lib/private/Files/Node/Node.php | 16 | ||||
-rw-r--r-- | lib/private/Files/Node/Root.php | 4 |
3 files changed, 18 insertions, 13 deletions
diff --git a/lib/private/Files/Node/Folder.php b/lib/private/Files/Node/Folder.php index 44f47e92ca0..9714a0aea00 100644 --- a/lib/private/Files/Node/Folder.php +++ b/lib/private/Files/Node/Folder.php @@ -330,8 +330,13 @@ class Folder extends Node implements \OCP\Files\Folder { * @return array */ protected function getByIdInRootMount(int $id): array { - $mount = $this->root->getMount(''); - $cacheEntry = $mount->getStorage()->getCache($this->path)->get($id); + $storage = null; + if (\method_exists($this->root, 'getMount')) { + /** @var IMountPoint $mount */ + $mount = $this->root->getMount(''); + $storage = $mount->getStorage(); + } + $cacheEntry = $storage?->getCache($this->path)->get($id); if (!$cacheEntry) { return []; } @@ -346,7 +351,7 @@ class Folder extends Node implements \OCP\Files\Folder { return [$this->root->createNode( $absolutePath, new \OC\Files\FileInfo( $absolutePath, - $mount->getStorage(), + $storage, $cacheEntry->getPath(), $cacheEntry, $mount diff --git a/lib/private/Files/Node/Node.php b/lib/private/Files/Node/Node.php index 4804f7046aa..4ba2c472c67 100644 --- a/lib/private/Files/Node/Node.php +++ b/lib/private/Files/Node/Node.php @@ -35,6 +35,7 @@ use OC\Files\Utils\PathHelper; use OCP\Files\FileInfo; use OCP\Files\InvalidPathException; use OCP\Files\IRootFolder; +use OCP\Files\Node as INode; use OCP\Files\NotFoundException; use OCP\Files\NotPermittedException; use OCP\Lock\LockedException; @@ -42,7 +43,7 @@ use OCP\PreConditionNotMetException; use Symfony\Component\EventDispatcher\GenericEvent; // FIXME: this class really should be abstract -class Node implements \OCP\Files\Node { +class Node implements INode { /** * @var \OC\Files\View $view */ @@ -128,7 +129,9 @@ class Node implements \OCP\Files\Node { $args = !empty($args) ? $args : [$this]; $dispatcher = \OC::$server->getEventDispatcher(); foreach ($hooks as $hook) { - $this->root->emit('\OC\Files', $hook, $args); + if (method_exists($this->root, 'emit')) { + $this->root->emit('\OC\Files', $hook, $args); + } $dispatcher->dispatch('\OCP\Files::' . $hook, new GenericEvent($args)); } } @@ -288,10 +291,7 @@ class Node implements \OCP\Files\Node { return $this->getFileInfo(false)->isCreatable(); } - /** - * @return Node - */ - public function getParent() { + public function getParent(): INode|IRootFolder { if ($this->parent === null) { $newPath = dirname($this->path); if ($newPath === '' || $newPath === '.' || $newPath === '/') { @@ -400,7 +400,7 @@ class Node implements \OCP\Files\Node { /** * @param string $targetPath - * @return \OCP\Files\Node + * @return INode * @throws InvalidPathException * @throws NotFoundException * @throws NotPermittedException if copy not allowed or failed @@ -426,7 +426,7 @@ class Node implements \OCP\Files\Node { /** * @param string $targetPath - * @return \OCP\Files\Node + * @return INode * @throws InvalidPathException * @throws NotFoundException * @throws NotPermittedException if move not allowed or failed diff --git a/lib/private/Files/Node/Root.php b/lib/private/Files/Node/Root.php index e9fb14e5364..0ed1bcab2ae 100644 --- a/lib/private/Files/Node/Root.php +++ b/lib/private/Files/Node/Root.php @@ -45,6 +45,7 @@ use OCP\Files\Config\IUserMountCache; use OCP\Files\Events\Node\FilesystemTornDownEvent; use OCP\Files\IRootFolder; use OCP\Files\Mount\IMountPoint; +use OCP\Files\Node as INode; use OCP\Files\NotFoundException; use OCP\Files\NotPermittedException; use OCP\IUser; @@ -339,10 +340,9 @@ class Root extends Folder implements IRootFolder { } /** - * @return Node * @throws \OCP\Files\NotFoundException */ - public function getParent() { + public function getParent(): INode|IRootFolder { throw new NotFoundException(); } |