}
public function execute(InputInterface $input, OutputInterface $output): int {
- $deletedEntries = 0;
$fileIdsByStorage = [];
$deletedStorages = array_diff($this->getReferencedStorages(), $this->getExistingStorages());
$fileIdsByStorage = $this->getFileIdsForStorages($deletedStorages);
}
- $deleteQuery = $this->connection->getQueryBuilder();
- $deleteQuery->delete('filecache')
- ->where($deleteQuery->expr()->in('storage', $deleteQuery->createParameter('storage_ids')));
-
- $deletedStorageChunks = array_chunk($deletedStorages, self::CHUNK_SIZE);
- foreach ($deletedStorageChunks as $deletedStorageChunk) {
- $deleteQuery->setParameter('storage_ids', $deletedStorageChunk, IQueryBuilder::PARAM_INT_ARRAY);
- $deletedEntries += $deleteQuery->executeStatement();
- }
-
+ $deletedEntries = $this->cleanupOrphanedFileCache($deletedStorages);
$output->writeln("$deletedEntries orphaned file cache entries deleted");
if ($deleteExtended) {
$output->writeln("$deletedFileCacheExtended orphaned file cache extended entries deleted");
}
-
$deletedMounts = $this->cleanupOrphanedMounts();
$output->writeln("$deletedMounts orphaned mount entries deleted");
+
return self::SUCCESS;
}
return $result;
}
+ private function cleanupOrphanedFileCache(array $deletedStorages): int {
+ $deletedEntries = 0;
+
+ $deleteQuery = $this->connection->getQueryBuilder();
+ $deleteQuery->delete('filecache')
+ ->where($deleteQuery->expr()->in('storage', $deleteQuery->createParameter('storage_ids')));
+
+ $deletedStorageChunks = array_chunk($deletedStorages, self::CHUNK_SIZE);
+ foreach ($deletedStorageChunks as $deletedStorageChunk) {
+ $deleteQuery->setParameter('storage_ids', $deletedStorageChunk, IQueryBuilder::PARAM_INT_ARRAY);
+ $deletedEntries += $deleteQuery->executeStatement();
+ }
+
+ return $deletedEntries;
+ }
+
/**
* @param array<int, int[]> $fileIdsByStorage
* @return int