aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorArthur Schiwon <blizzz@arthur-schiwon.de>2023-06-08 23:32:16 +0200
committerArthur Schiwon <blizzz@arthur-schiwon.de>2023-07-04 23:10:25 +0200
commitd5b69c16984163ba0f8c0a8001cf31fbba167b5f (patch)
tree9c4525f3a7bb119253a8e7345938375fb35fefa2 /lib
parente5e9df2948e32d1fedbf3c0f3e0b87e42e361128 (diff)
downloadnextcloud-server-d5b69c16984163ba0f8c0a8001cf31fbba167b5f.tar.gz
nextcloud-server-d5b69c16984163ba0f8c0a8001cf31fbba167b5f.zip
chore: ugly type juggling
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Diffstat (limited to 'lib')
-rw-r--r--lib/private/Files/Cache/QuerySearchHelper.php18
-rw-r--r--lib/private/Files/FileInfo.php3
-rw-r--r--lib/private/Files/Node/Folder.php11
-rw-r--r--lib/private/Files/Node/Node.php16
-rw-r--r--lib/private/Files/Node/Root.php4
5 files changed, 32 insertions, 20 deletions
diff --git a/lib/private/Files/Cache/QuerySearchHelper.php b/lib/private/Files/Cache/QuerySearchHelper.php
index 6a78f585c48..a17cc02d37b 100644
--- a/lib/private/Files/Cache/QuerySearchHelper.php
+++ b/lib/private/Files/Cache/QuerySearchHelper.php
@@ -196,23 +196,33 @@ class QuerySearchHelper {
}
/**
- * @return array{array<string, ICache>, array<string, IMountPoint>}
+ * @return list{0?: array<array-key, ICache>, 1?: array<array-key, IMountPoint>}
*/
public function getCachesAndMountPointsForSearch(IRootFolder $root, string $path, bool $limitToHome = false): array {
$rootLength = strlen($path);
- $mount = $root->getMount($path);
- $storage = $mount->getStorage();
+ $storage = null;
+ if (method_exists($root, 'getMount')) {
+ /** @var IMountPoint $mount */
+ $mount = $root->getMount($path);
+ $storage = $mount->getStorage();
+ }
+ if ($storage === null) {
+ return [];
+ }
$internalPath = $mount->getInternalPath($path);
if ($internalPath !== '') {
// a temporary CacheJail is used to handle filtering down the results to within this folder
+ /** @var ICache[] $caches */
$caches = ['' => new CacheJail($storage->getCache(''), $internalPath)];
} else {
+ /** @var ICache[] $caches */
$caches = ['' => $storage->getCache('')];
}
+ /** @var IMountPoint[] $mountByMountPoint */
$mountByMountPoint = ['' => $mount];
- if (!$limitToHome) {
+ if (!$limitToHome && method_exists($root, 'getMountsIn')) {
/** @var IMountPoint[] $mounts */
$mounts = $root->getMountsIn($path);
foreach ($mounts as $mount) {
diff --git a/lib/private/Files/FileInfo.php b/lib/private/Files/FileInfo.php
index 47c893ebbf1..70f700d2d73 100644
--- a/lib/private/Files/FileInfo.php
+++ b/lib/private/Files/FileInfo.php
@@ -149,9 +149,6 @@ class FileInfo implements \OCP\Files\FileInfo, \ArrayAccess {
return $this->path;
}
- /**
- * @return \OCP\Files\Storage
- */
public function getStorage() {
return $this->storage;
}
diff --git a/lib/private/Files/Node/Folder.php b/lib/private/Files/Node/Folder.php
index e6bae29807d..79a8b88fc88 100644
--- a/lib/private/Files/Node/Folder.php
+++ b/lib/private/Files/Node/Folder.php
@@ -329,8 +329,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 [];
}
@@ -345,7 +350,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 9a1630ebde0..7c8c0197834 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
*/
@@ -122,7 +123,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));
}
}
@@ -282,10 +285,7 @@ class Node implements \OCP\Files\Node {
return $this->getFileInfo()->isCreatable();
}
- /**
- * @return Node
- */
- public function getParent() {
+ public function getParent(): INode|IRootFolder {
if ($this->parent === null) {
$newPath = dirname($this->path);
if ($newPath === '' || $newPath === '.' || $newPath === '/') {
@@ -394,7 +394,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
@@ -420,7 +420,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 ca930c1002c..2de71c1500e 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();
}