diff options
author | Roeland Jago Douma <rullzer@users.noreply.github.com> | 2021-03-30 21:10:05 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-30 21:10:05 +0200 |
commit | 7c30d1aa2d27d81a067c1e8a52e6512f15f88d4d (patch) | |
tree | f636319c1bad22c700aa538a7bf106a69c905cc0 /lib | |
parent | 06ae9c3dc7dd14717ada7af7053405cf08c7dc9a (diff) | |
parent | 8a92229485095dbd8f379e2b489a3aa48cc37c79 (diff) | |
download | nextcloud-server-7c30d1aa2d27d81a067c1e8a52e6512f15f88d4d.tar.gz nextcloud-server-7c30d1aa2d27d81a067c1e8a52e6512f15f88d4d.zip |
Merge pull request #26219 from nextcloud/relative-path-null
getRelativePath can return null
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/Files/Filesystem.php | 2 | ||||
-rw-r--r-- | lib/private/Files/Mount/MountPoint.php | 4 | ||||
-rw-r--r-- | lib/private/Files/Node/Folder.php | 4 | ||||
-rw-r--r-- | lib/private/Search/Result/File.php | 6 | ||||
-rw-r--r-- | lib/public/Files/Folder.php | 2 | ||||
-rw-r--r-- | lib/public/Files/Mount/IMountPoint.php | 2 |
6 files changed, 12 insertions, 8 deletions
diff --git a/lib/private/Files/Filesystem.php b/lib/private/Files/Filesystem.php index bf94be273f2..fade3b69fbb 100644 --- a/lib/private/Files/Filesystem.php +++ b/lib/private/Files/Filesystem.php @@ -312,7 +312,7 @@ class Filesystem { * get the storage mounted at $mountPoint * * @param string $mountPoint - * @return \OC\Files\Storage\Storage + * @return \OC\Files\Storage\Storage|null */ public static function getStorage($mountPoint) { if (!self::$mounts) { diff --git a/lib/private/Files/Mount/MountPoint.php b/lib/private/Files/Mount/MountPoint.php index cbf3785c409..891bbc41c36 100644 --- a/lib/private/Files/Mount/MountPoint.php +++ b/lib/private/Files/Mount/MountPoint.php @@ -39,7 +39,7 @@ use OCP\ILogger; class MountPoint implements IMountPoint { /** - * @var \OC\Files\Storage\Storage $storage + * @var \OC\Files\Storage\Storage|null $storage */ protected $storage = null; protected $class; @@ -167,7 +167,7 @@ class MountPoint implements IMountPoint { } /** - * @return \OC\Files\Storage\Storage + * @return \OC\Files\Storage\Storage|null */ public function getStorage() { if (is_null($this->storage)) { diff --git a/lib/private/Files/Node/Folder.php b/lib/private/Files/Node/Folder.php index 36c4cbe58bc..7b1eff47cd5 100644 --- a/lib/private/Files/Node/Folder.php +++ b/lib/private/Files/Node/Folder.php @@ -76,7 +76,7 @@ class Folder extends Node implements \OCP\Files\Folder { /** * @param string $path - * @return string + * @return string|null */ public function getRelativePath($path) { if ($this->path === '' or $this->path === '/') { @@ -494,7 +494,7 @@ class Folder extends Node implements \OCP\Files\Folder { $mounts[] = $this->getMountPoint(); $mounts = array_filter($mounts, function (IMountPoint $mount) { - return $mount->getStorage(); + return $mount->getStorage() !== null; }); $storageIds = array_map(function (IMountPoint $mount) { return $mount->getStorage()->getCache()->getNumericStorageId(); diff --git a/lib/private/Search/Result/File.php b/lib/private/Search/Result/File.php index c3b0c4e3751..f8779f8ccbd 100644 --- a/lib/private/Search/Result/File.php +++ b/lib/private/Search/Result/File.php @@ -133,7 +133,11 @@ class File extends \OCP\Search\Result { $userID = $userSession->getUser()->getUID(); self::$userFolderCache = \OC::$server->getUserFolder($userID); } - return self::$userFolderCache->getRelativePath($path); + $relativePath = self::$userFolderCache->getRelativePath($path); + if ($relativePath === null) { + throw new \Exception("Search result not in user folder"); + } + return $relativePath; } /** diff --git a/lib/public/Files/Folder.php b/lib/public/Files/Folder.php index 3e90abdd944..292d53d7767 100644 --- a/lib/public/Files/Folder.php +++ b/lib/public/Files/Folder.php @@ -55,7 +55,7 @@ interface Folder extends Node { * * @param string $path absolute path of an item in the folder * @throws \OCP\Files\NotFoundException - * @return string + * @return string|null * @since 6.0.0 */ public function getRelativePath($path); diff --git a/lib/public/Files/Mount/IMountPoint.php b/lib/public/Files/Mount/IMountPoint.php index 7315fd97035..51a5fbade48 100644 --- a/lib/public/Files/Mount/IMountPoint.php +++ b/lib/public/Files/Mount/IMountPoint.php @@ -48,7 +48,7 @@ interface IMountPoint { /** * Get the storage that is mounted * - * @return \OC\Files\Storage\Storage + * @return \OC\Files\Storage\Storage|null * @since 8.0.0 */ public function getStorage(); |