fix(perf): use index when deleting old previews

Signed-off-by: Benjamin Gaussorgues <benjamin.gaussorgues@nextcloud.com>
pull/58431/head
Benjamin Gaussorgues 2 weeks ago committed by backportbot[bot]
parent cad2e6dc6b
commit fd925b95ce
  1. 6
      lib/private/Preview/PreviewMigrationService.php

@ -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);

Loading…
Cancel
Save