]> source.dussan.org Git - nextcloud-server.git/commitdiff
Better handle return values from Filesystem::getMountBy*
authorRobin McCorkell <rmccorkell@karoshi.org.uk>
Mon, 21 Apr 2014 10:35:52 +0000 (11:35 +0100)
committerRobin McCorkell <rmccorkell@karoshi.org.uk>
Fri, 25 Apr 2014 08:50:34 +0000 (09:50 +0100)
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

apps/files_sharing/lib/cache.php
apps/files_sharing/lib/sharedstorage.php
lib/private/share/share.php

index 67a0410ef76889db5467d15468e6c2f90bbca889..a30bb865e5782a73ceff49ead1497fa592405ae5 100644 (file)
@@ -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) {
index 5e478d5ead8557435df085bcb7632c887a3d4df4..2252ec6a1a6af9ff9a82fce6b530e8d7bbc27876 100644 (file)
@@ -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'];
index c0ce3a1d8af357e96f7ef3282f105577936bc8ed..b12d62e8439a7f7fd2821f280b715d8d3ab4835e 100644 (file)
@@ -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);
                                                }
                                        }