Skip to content

Commit

Permalink
Get shared storage numeric id directly from DB
Browse files Browse the repository at this point in the history
To prevent recursions in initMountPoints which requires the numeric id
to populate oc_mounts
  • Loading branch information
Vincent Petry committed Aug 15, 2016
1 parent 4033a6b commit c8a385d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
9 changes: 9 additions & 0 deletions apps/files_sharing/lib/SharedMount.php
Original file line number Diff line number Diff line change
Expand Up @@ -233,4 +233,13 @@ public function getShare() {
public function getStorageRootId() {
return $this->getShare()->getNodeId();
}

public function getStorageNumericId() {
$query = \OC::$server->getDatabaseConnection()->getQueryBuilder();
$query->select('storage')
->from('filecache')
->where($query->expr()->eq('fileid', $query->createNamedParameter($this->share->getNodeId())));

return $query->execute()->fetchColumn();
}
}
12 changes: 8 additions & 4 deletions lib/private/Files/Config/LazyStorageMountInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,15 @@ public function __construct(IUser $user, IMountPoint $mount) {
*/
public function getStorageId() {
if (!$this->storageId) {
$storage = $this->mount->getStorage();
if (!$storage) {
return -1;
if (method_exists($this->mount, 'getStorageNumericId')) {
$this->storageId = $this->mount->getStorageNumericId();
} else {
$storage = $this->mount->getStorage();
if (!$storage) {
return -1;
}
$this->storageId = $storage->getStorageCache()->getNumericId();
}
$this->storageId = $storage->getStorageCache()->getNumericId();
}
return parent::getStorageId();
}
Expand Down

0 comments on commit c8a385d

Please sign in to comment.