Merge pull request #25076 from owncloud/mount-cache-invalid

handle invalid storages in LazyStorageMountInfo
This commit is contained in:
Vincent Petry 2016-06-14 10:52:21 +02:00 committed by GitHub
commit ce676c4eb6
2 changed files with 16 additions and 8 deletions

View File

@ -28,7 +28,7 @@ use OCP\Files\Node;
use OCP\IUser; use OCP\IUser;
class LazyStorageMountInfo extends CachedMountInfo { class LazyStorageMountInfo extends CachedMountInfo {
/** @var IMountPoint */ /** @var IMountPoint */
private $mount; private $mount;
/** /**
@ -47,7 +47,11 @@ class LazyStorageMountInfo extends CachedMountInfo {
*/ */
public function getStorageId() { public function getStorageId() {
if (!$this->storageId) { 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(); return parent::getStorageId();
} }

View File

@ -124,12 +124,16 @@ class UserMountCache implements IUserMountCache {
} }
private function addToCache(ICachedMountInfo $mount) { private function addToCache(ICachedMountInfo $mount) {
$this->connection->insertIfNotExist('*PREFIX*mounts', [ if ($mount->getStorageId() !== -1) {
'storage_id' => $mount->getStorageId(), $this->connection->insertIfNotExist('*PREFIX*mounts', [
'root_id' => $mount->getRootId(), 'storage_id' => $mount->getStorageId(),
'user_id' => $mount->getUser()->getUID(), 'root_id' => $mount->getRootId(),
'mount_point' => $mount->getMountPoint() 'user_id' => $mount->getUser()->getUID(),
], ['root_id', 'user_id']); '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) { private function setMountPoint(ICachedMountInfo $mount) {