From 00539cf8f9591639ca82caea22b41fd1d95a558b Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Wed, 4 Jun 2014 17:08:25 +0200 Subject: [PATCH 1/2] Verify that we have a valid storage in View->getPath --- lib/private/files/view.php | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/lib/private/files/view.php b/lib/private/files/view.php index 09b100d7cf..6eacf34d72 100644 --- a/lib/private/files/view.php +++ b/lib/private/files/view.php @@ -359,7 +359,8 @@ class View { $absolutePath = Filesystem::normalizePath($this->getAbsolutePath($path)); list($storage, $internalPath) = Filesystem::resolvePath($absolutePath . $postFix); if (!($storage instanceof \OC\Files\Storage\Shared) && - (!$internalPath || $internalPath === '' || $internalPath === '/')) { + (!$internalPath || $internalPath === '' || $internalPath === '/') + ) { // do not allow deleting the storage's root / the mount point // because for some storages it might delete the whole contents // but isn't supposed to work that way @@ -678,6 +679,7 @@ class View { /** * abstraction layer for basic filesystem functions: wrapper for \OC\Files\Storage\Storage + * * @param string $operation * @param string $path * @param array $hooks (optional) @@ -1138,12 +1140,14 @@ class View { /** * @var \OC\Files\Mount\Mount $mount */ - $cache = $mount->getStorage()->getCache(); - $internalPath = $cache->getPathById($id); - if (is_string($internalPath)) { - $fullPath = $mount->getMountPoint() . $internalPath; - if (!is_null($path = $this->getRelativePath($fullPath))) { - return $path; + if ($mount->getStorage()) { + $cache = $mount->getStorage()->getCache(); + $internalPath = $cache->getPathById($id); + if (is_string($internalPath)) { + $fullPath = $mount->getMountPoint() . $internalPath; + if (!is_null($path = $this->getRelativePath($fullPath))) { + return $path; + } } } } From d359765bdc028eef18a4aab05944faa9ced596ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20M=C3=BCller?= Date: Fri, 6 Jun 2014 09:44:34 +0200 Subject: [PATCH 2/2] Update PHPDoc --- lib/private/files/view.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/private/files/view.php b/lib/private/files/view.php index 6eacf34d72..1dc6c405bc 100644 --- a/lib/private/files/view.php +++ b/lib/private/files/view.php @@ -1127,7 +1127,7 @@ class View { * Note that the resulting path is not guarantied to be unique for the id, multiple paths can point to the same file * * @param int $id - * @return string + * @return string|null */ public function getPath($id) { $manager = Filesystem::getMountManager();