diff options
author | Vincent Petry <pvince81@owncloud.com> | 2016-06-14 10:52:21 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-06-14 10:52:21 +0200 |
commit | ce676c4eb6172763a86c1fa1501cd6120d8c119a (patch) | |
tree | f231025b480c8e38d0e23fd4e2adffb1d860d4fb /lib/private | |
parent | d0a2515e2b08bffac3e3f447cc78c24f372a0589 (diff) | |
parent | 338cd4033ac0662a4077825d2084f53645af1865 (diff) | |
download | nextcloud-server-ce676c4eb6172763a86c1fa1501cd6120d8c119a.tar.gz nextcloud-server-ce676c4eb6172763a86c1fa1501cd6120d8c119a.zip |
Merge pull request #25076 from owncloud/mount-cache-invalid
handle invalid storages in LazyStorageMountInfo
Diffstat (limited to 'lib/private')
-rw-r--r-- | lib/private/Files/Config/LazyStorageMountInfo.php | 8 | ||||
-rw-r--r-- | lib/private/Files/Config/UserMountCache.php | 16 |
2 files changed, 16 insertions, 8 deletions
diff --git a/lib/private/Files/Config/LazyStorageMountInfo.php b/lib/private/Files/Config/LazyStorageMountInfo.php index 654c5b2b23e..5df04c4b78e 100644 --- a/lib/private/Files/Config/LazyStorageMountInfo.php +++ b/lib/private/Files/Config/LazyStorageMountInfo.php @@ -28,7 +28,7 @@ use OCP\Files\Node; use OCP\IUser; class LazyStorageMountInfo extends CachedMountInfo { - /** @var IMountPoint */ + /** @var IMountPoint */ private $mount; /** @@ -47,7 +47,11 @@ class LazyStorageMountInfo extends CachedMountInfo { */ public function getStorageId() { if (!$this->storageId) { - $this->storageId = $this->mount->getStorage()->getStorageCache()->getNumericId(); + $storage = $this->mount->getStorage(); + if (!$storage) { + return -1; + } + $this->storageId = $storage->getStorageCache()->getNumericId(); } return parent::getStorageId(); } diff --git a/lib/private/Files/Config/UserMountCache.php b/lib/private/Files/Config/UserMountCache.php index edb1525b276..c9470048601 100644 --- a/lib/private/Files/Config/UserMountCache.php +++ b/lib/private/Files/Config/UserMountCache.php @@ -124,12 +124,16 @@ class UserMountCache implements IUserMountCache { } private function addToCache(ICachedMountInfo $mount) { - $this->connection->insertIfNotExist('*PREFIX*mounts', [ - 'storage_id' => $mount->getStorageId(), - 'root_id' => $mount->getRootId(), - 'user_id' => $mount->getUser()->getUID(), - 'mount_point' => $mount->getMountPoint() - ], ['root_id', 'user_id']); + if ($mount->getStorageId() !== -1) { + $this->connection->insertIfNotExist('*PREFIX*mounts', [ + 'storage_id' => $mount->getStorageId(), + 'root_id' => $mount->getRootId(), + 'user_id' => $mount->getUser()->getUID(), + 'mount_point' => $mount->getMountPoint() + ], ['root_id', 'user_id']); + } else { + $this->logger->error('Error getting storage info for mount at ' . $mount->getMountPoint()); + } } private function setMountPoint(ICachedMountInfo $mount) { |