fix(perf): use index when deleting old previews

Signed-off-by: Benjamin Gaussorgues <benjamin.gaussorgues@nextcloud.com>
This commit is contained in:
Benjamin Gaussorgues 2026-02-18 15:46:50 +01:00
parent a6d1fa1fa6
commit 30e35a8411
No known key found for this signature in database

View file

@ -161,12 +161,16 @@ class PreviewMigrationService {
private function deleteFolder(string $path): void {
$current = $path;
$rootFolderId = $this->rootFolder->getMountPoint()->getNumericStorageId();
while (true) {
$appDataPath = $this->previewRootPath . $current;
$qb = $this->connection->getQueryBuilder();
$qb->delete('filecache')
->where($qb->expr()->eq('path_hash', $qb->createNamedParameter(md5($appDataPath))))
->hintShardKey('storage', $this->rootFolder->getMountPoint()->getNumericStorageId())
->andWhere($qb->expr()->eq(
'storage',
$qb->createNamedParameter($rootFolderId),
))
->executeStatement();
$current = dirname($current);