|
|
@@ -17,10 +17,10 @@ use JetBrains\PhpStorm\Pure;
|
|
|
/**
|
|
|
* Cronjob that delete files with host 'ap2i' and status DELETION_REQUESTED.
|
|
|
*
|
|
|
- * >>> ot:cron run clean-files-to-delete --preview
|
|
|
- * >>> ot:cron run clean-files-to-delete
|
|
|
+ * >>> ot:cron run files-garbage-collector --preview
|
|
|
+ * >>> ot:cron run files-garbage-collector
|
|
|
*/
|
|
|
-class CleanFilesToDelete extends BaseCronJob
|
|
|
+class FilesGarbageCollector extends BaseCronJob
|
|
|
{
|
|
|
#[Pure]
|
|
|
public function __construct(
|
|
|
@@ -91,7 +91,6 @@ class CleanFilesToDelete extends BaseCronJob
|
|
|
$total = count($files);
|
|
|
$this->logger->info($total.' files to be removed');
|
|
|
|
|
|
- $this->connection->setAutoCommit(false);
|
|
|
$queryBuilder = $this->fileRepository->createQueryBuilder('f');
|
|
|
|
|
|
$this->logger->info('Deleting files...');
|
|
|
@@ -100,7 +99,6 @@ class CleanFilesToDelete extends BaseCronJob
|
|
|
$this->ui->progress(0, $total);
|
|
|
|
|
|
foreach ($files as $file) {
|
|
|
- $this->connection->beginTransaction();
|
|
|
$this->ui->progress($i, $total);
|
|
|
++$i;
|
|
|
|
|
|
@@ -111,14 +109,11 @@ class CleanFilesToDelete extends BaseCronJob
|
|
|
// Remove from DB
|
|
|
$queryBuilder->delete()->where('f.id = :id')->setParameter('id', $file->getId());
|
|
|
|
|
|
- $this->connection->commit();
|
|
|
++$deleted;
|
|
|
} catch (\RuntimeException|\InvalidArgumentException $e) {
|
|
|
// Non blocking errors
|
|
|
- $this->connection->rollback();
|
|
|
$this->logger->error('ERROR : '.$e->getMessage());
|
|
|
} catch (\Exception $exception) {
|
|
|
- $this->connection->rollback();
|
|
|
throw $exception;
|
|
|
}
|
|
|
}
|