diff options
Diffstat (limited to 'apps')
-rw-r--r-- | apps/files/lib/Command/DeleteOrphanedFiles.php | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/apps/files/lib/Command/DeleteOrphanedFiles.php b/apps/files/lib/Command/DeleteOrphanedFiles.php index 966351e4da0..d07337594a1 100644 --- a/apps/files/lib/Command/DeleteOrphanedFiles.php +++ b/apps/files/lib/Command/DeleteOrphanedFiles.php @@ -34,7 +34,6 @@ class DeleteOrphanedFiles extends Command { } public function execute(InputInterface $input, OutputInterface $output): int { - $deletedEntries = 0; $fileIdsByStorage = []; $deletedStorages = array_diff($this->getReferencedStorages(), $this->getExistingStorages()); @@ -44,16 +43,7 @@ class DeleteOrphanedFiles extends Command { $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) { @@ -61,9 +51,9 @@ class DeleteOrphanedFiles extends Command { $output->writeln("$deletedFileCacheExtended orphaned file cache extended entries deleted"); } - $deletedMounts = $this->cleanupOrphanedMounts(); $output->writeln("$deletedMounts orphaned mount entries deleted"); + return self::SUCCESS; } @@ -106,6 +96,22 @@ class DeleteOrphanedFiles extends Command { 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 |