summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobin McCorkell <rmccorkell@karoshi.org.uk>2014-04-21 11:35:52 +0100
committerRobin McCorkell <rmccorkell@karoshi.org.uk>2014-04-25 09:50:34 +0100
commit77e3d067f03ba334fc1b06f8d2177006ef859822 (patch)
treee22d6f73a419b8cfe5ca17493d7d15d425c44b68
parent3fc809dfd80a296d7da922a06f9e13d446b3d3f0 (diff)
downloadnextcloud-server-77e3d067f03ba334fc1b06f8d2177006ef859822.tar.gz
nextcloud-server-77e3d067f03ba334fc1b06f8d2177006ef859822.zip
Better handle return values from Filesystem::getMountBy*
getMountByStorageId and getMountByNumericId return an empty array on error, which should be detected to avoid possible errors. This commit also adds in some new logging points and throws to aid debugging
-rw-r--r--apps/files_sharing/lib/cache.php2
-rw-r--r--apps/files_sharing/lib/sharedstorage.php3
-rw-r--r--lib/private/share/share.php2
3 files changed, 4 insertions, 3 deletions
diff --git a/apps/files_sharing/lib/cache.php b/apps/files_sharing/lib/cache.php
index 67a0410ef76..a30bb865e57 100644
--- a/apps/files_sharing/lib/cache.php
+++ b/apps/files_sharing/lib/cache.php
@@ -54,7 +54,7 @@ class Shared_Cache extends Cache {
if (isset($source['path']) && isset($source['fileOwner'])) {
\OC\Files\Filesystem::initMountPoints($source['fileOwner']);
$mounts = \OC\Files\Filesystem::getMountByNumericId($source['storage']);
- if (is_array($mounts) and count($mounts)) {
+ if (is_array($mounts) and !empty($mounts)) {
$fullPath = $mounts[0]->getMountPoint() . $source['path'];
list($storage, $internalPath) = \OC\Files\Filesystem::resolvePath($fullPath);
if ($storage) {
diff --git a/apps/files_sharing/lib/sharedstorage.php b/apps/files_sharing/lib/sharedstorage.php
index 5e478d5ead8..2252ec6a1a6 100644
--- a/apps/files_sharing/lib/sharedstorage.php
+++ b/apps/files_sharing/lib/sharedstorage.php
@@ -87,10 +87,11 @@ class Shared extends \OC\Files\Storage\Common {
if (!isset($source['fullPath'])) {
\OC\Files\Filesystem::initMountPoints($source['fileOwner']);
$mount = \OC\Files\Filesystem::getMountByNumericId($source['storage']);
- if (is_array($mount)) {
+ if (is_array($mount) && !empty($mount)) {
$this->files[$target]['fullPath'] = $mount[key($mount)]->getMountPoint() . $source['path'];
} else {
$this->files[$target]['fullPath'] = false;
+ \OCP\Util::writeLog('files_sharing', "Unable to get mount for shared storage '" . $source['storage'] . "' user '" . $source['fileOwner'] . "'", \OCP\Util::ERROR);
}
}
return $this->files[$target]['fullPath'];
diff --git a/lib/private/share/share.php b/lib/private/share/share.php
index c0ce3a1d8af..b12d62e8439 100644
--- a/lib/private/share/share.php
+++ b/lib/private/share/share.php
@@ -1228,7 +1228,7 @@ class Share extends \OC\Share\Constants {
} else {
if (!isset($mounts[$row['storage']])) {
$mountPoints = \OC\Files\Filesystem::getMountByNumericId($row['storage']);
- if (is_array($mountPoints)) {
+ if (is_array($mountPoints) && !empty($mountPoints)) {
$mounts[$row['storage']] = current($mountPoints);
}
}