Skip to content

Commit 7118fb3

Browse files
icewind1991juliusknorr
authored andcommitted
fix: make CollectiveFolderManager with sharding
Signed-off-by: Robin Appelman <robin@icewind.nl>
1 parent 5b986fb commit 7118fb3

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

lib/Mount/CollectiveFolderManager.php

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class CollectiveFolderManager {
3737
private const SUFFIX = '.md';
3838

3939
private ?string $rootPath = null;
40-
private ?int $rootFolderStorageId = null;
40+
private ?int $rootFolderId = null;
4141

4242
public function __construct(
4343
private IRootFolder $rootFolder,
@@ -150,19 +150,23 @@ private function getJailPath(int $folderId): string {
150150
/**
151151
* @throws NotFoundException
152152
*/
153-
private function getFolderRootId(): int {
154-
if ($this->rootFolderStorageId === null) {
153+
private function getRootFolderId(): int {
154+
if ($this->rootFolderId === null) {
155155
$qb = $this->connection->getQueryBuilder();
156156

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

162-
$this->rootFolderStorageId = (int)$qb->execute()->fetchColumn();
162+
$this->rootFolderId = (int)$qb->execute()->fetchColumn();
163163
}
164164

165-
return $this->rootFolderStorageId;
165+
return $this->rootFolderId;
166+
}
167+
168+
private function getRootFolderStorageId(): int {
169+
return $this->getRootFolder()->getStorage()->getCache()->getNumericStorageId();
166170
}
167171

168172
/**
@@ -198,10 +202,10 @@ public function getFolderFileCache(int $id, string $name): array {
198202
'co.id AS folder_id', 'fc.fileid', 'fc.storage', 'fc.path', 'fc.name AS name',
199203
'fc.mimetype', 'fc.mimepart', 'fc.size', 'fc.mtime', 'fc.storage_mtime', 'fc.etag', 'fc.encrypted', 'fc.parent', 'fc.permissions AS permissions')
200204
->from('collectives', 'co')
201-
->leftJoin('co', 'filecache', 'fc', $qb->expr()->andX(
202-
$qb->expr()->eq('fc.name', $qb->expr()->castColumn('co.id', IQueryBuilder::PARAM_STR)),
203-
$qb->expr()->eq('fc.parent', $qb->createNamedParameter($this->getFolderRootId()))))
204-
->where($qb->expr()->eq('co.id', $qb->createNamedParameter($id)));
205+
->leftJoin('co', 'filecache', 'fc', $qb->expr()->eq('fc.name', $qb->expr()->castColumn('co.id', IQueryBuilder::PARAM_STR)))
206+
->where($qb->expr()->eq('co.id', $qb->createNamedParameter($id)))
207+
->andWhere($qb->expr()->eq('fc.parent', $qb->createNamedParameter($this->getRootFolderId())))
208+
->andWhere($qb->expr()->eq('fc.storage', $qb->createNamedParameter($this->getRootFolderStorageId(), IQueryBuilder::PARAM_INT)));
205209
$cache = $qb->execute()->fetch();
206210
$cache['mount_point'] = $name;
207211
return $cache;

0 commit comments

Comments
 (0)