Skip to content

Commit

Permalink
fix: make CollectiveFolderManager with sharding
Browse files Browse the repository at this point in the history
Signed-off-by: Robin Appelman <[email protected]>
  • Loading branch information
icewind1991 authored and juliusknorr committed Jan 14, 2025
1 parent 5b986fb commit a90645c
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions lib/Mount/CollectiveFolderManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ private function getFolderRootId(): int {

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

$this->rootFolderStorageId = (int)$qb->execute()->fetchColumn();
Expand All @@ -165,6 +165,10 @@ private function getFolderRootId(): int {
return $this->rootFolderStorageId;
}

private function getRootFolderStorageId(): int {
return $this->getRootFolder()->getStorage()->getCache()->getNumericStorageId();
}

/**
* @throws NotPermittedException
*/
Expand Down Expand Up @@ -198,10 +202,10 @@ public function getFolderFileCache(int $id, string $name): array {
'co.id AS folder_id', 'fc.fileid', 'fc.storage', 'fc.path', 'fc.name AS name',
'fc.mimetype', 'fc.mimepart', 'fc.size', 'fc.mtime', 'fc.storage_mtime', 'fc.etag', 'fc.encrypted', 'fc.parent', 'fc.permissions AS permissions')
->from('collectives', 'co')
->leftJoin('co', 'filecache', 'fc', $qb->expr()->andX(
$qb->expr()->eq('fc.name', $qb->expr()->castColumn('co.id', IQueryBuilder::PARAM_STR)),
$qb->expr()->eq('fc.parent', $qb->createNamedParameter($this->getFolderRootId()))))
->where($qb->expr()->eq('co.id', $qb->createNamedParameter($id)));
->leftJoin('co', 'filecache', 'fc', $qb->expr()->eq('fc.name', $qb->expr()->castColumn('co.id', IQueryBuilder::PARAM_STR)))
->where($qb->expr()->eq('co.id', $qb->createNamedParameter($id)))
->andWhere($qb->expr()->eq('fc.parent', $qb->createNamedParameter($this->getFolderRootId())))
->andWhere($qb->expr()->eq('fc.storage', $qb->createNamedParameter($this->getRootFolderStorageId(), IQueryBuilder::PARAM_INT)));
$cache = $qb->execute()->fetch();
$cache['mount_point'] = $name;
return $cache;
Expand Down

0 comments on commit a90645c

Please sign in to comment.