Skip to content

Commit

Permalink
Cache the root storage id locally
Browse files Browse the repository at this point in the history
Signed-off-by: Julius Härtl <jus@bitgrid.net>
  • Loading branch information
juliusknorr committed Dec 21, 2022
1 parent 2fe10ab commit e0567bb
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions lib/Mount/CollectiveFolderManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ class CollectiveFolderManager {
private IRequest $request;
private ?string $rootPath = null;

/** @var int|null */
private $rootFolderStorageId = null;

/**
* CollectiveFolderManager constructor.
*
Expand Down Expand Up @@ -185,14 +188,18 @@ private function getJailPath(int $folderId): string {
* @throws NotFoundException
*/
private function getRootFolderStorageId(): int {
$qb = $this->connection->getQueryBuilder();
if ($this->rootFolderStorageId === null) {
$qb = $this->connection->getQueryBuilder();

$qb->select('fileid')
->from('filecache')
->where($qb->expr()->eq('storage', $qb->createNamedParameter($this->getRootFolder()->getStorage()->getCache()->getNumericStorageId())))
->andWhere($qb->expr()->eq('path_hash', $qb->createNamedParameter(md5($this->getRootPath()))));
$qb->select('fileid')
->from('filecache')
->where($qb->expr()->eq('storage', $qb->createNamedParameter($this->getRootFolder()->getStorage()->getCache()->getNumericStorageId())))
->andWhere($qb->expr()->eq('path_hash', $qb->createNamedParameter(md5($this->getRootPath()))));

$this->rootFolderStorageId = (int)$qb->execute()->fetchColumn();
}

return (int)$qb->execute()->fetchColumn();
return $this->rootFolderStorageId;
}

/**
Expand Down

0 comments on commit e0567bb

Please sign in to comment.