Merge pull request #8877 from owncloud/getpath-storage-check

Verify that we have a valid storage in View->getPath
This commit is contained in:
Thomas Müller 2014-06-06 09:44:57 +02:00
commit 79b65269c9
1 changed files with 12 additions and 8 deletions

View File

@ -359,7 +359,8 @@ class View {
$absolutePath = Filesystem::normalizePath($this->getAbsolutePath($path)); $absolutePath = Filesystem::normalizePath($this->getAbsolutePath($path));
list($storage, $internalPath) = Filesystem::resolvePath($absolutePath . $postFix); list($storage, $internalPath) = Filesystem::resolvePath($absolutePath . $postFix);
if (!($storage instanceof \OC\Files\Storage\Shared) && if (!($storage instanceof \OC\Files\Storage\Shared) &&
(!$internalPath || $internalPath === '' || $internalPath === '/')) { (!$internalPath || $internalPath === '' || $internalPath === '/')
) {
// do not allow deleting the storage's root / the mount point // do not allow deleting the storage's root / the mount point
// because for some storages it might delete the whole contents // because for some storages it might delete the whole contents
// but isn't supposed to work that way // 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 * abstraction layer for basic filesystem functions: wrapper for \OC\Files\Storage\Storage
*
* @param string $operation * @param string $operation
* @param string $path * @param string $path
* @param array $hooks (optional) * @param array $hooks (optional)
@ -1125,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 * 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 * @param int $id
* @return string * @return string|null
*/ */
public function getPath($id) { public function getPath($id) {
$manager = Filesystem::getMountManager(); $manager = Filesystem::getMountManager();
@ -1138,6 +1140,7 @@ class View {
/** /**
* @var \OC\Files\Mount\Mount $mount * @var \OC\Files\Mount\Mount $mount
*/ */
if ($mount->getStorage()) {
$cache = $mount->getStorage()->getCache(); $cache = $mount->getStorage()->getCache();
$internalPath = $cache->getPathById($id); $internalPath = $cache->getPathById($id);
if (is_string($internalPath)) { if (is_string($internalPath)) {
@ -1147,6 +1150,7 @@ class View {
} }
} }
} }
}
return null; return null;
} }