Change Delete Command

This commit is contained in:
Jürgen Mummert
2026-01-05 10:25:58 +01:00
parent b684267541
commit d9b8646835
@@ -11,8 +11,6 @@ use Symfony\Component\Console\Output\OutputInterface;
class MeilisearchFilesCleanupCommand extends Command
{
protected static $defaultName = 'meilisearch:files:cleanup';
public function __construct(
private readonly ContaoFramework $framework,
) {
@@ -22,13 +20,14 @@ class MeilisearchFilesCleanupCommand extends Command
protected function configure(): void
{
$this
->setDescription('Removes stale indexed files (PDF, DOCX, XLSX, PPTX) from tl_search_pdf')
->setName('meilisearch:files:cleanup')
->setDescription('Remove stale indexed files (PDF, DOCX, XLSX, PPTX) from tl_search_pdf')
->addOption(
'grace',
null,
InputOption::VALUE_OPTIONAL,
'Grace period in seconds (files newer than now-grace are kept)',
3600 // 1 Stunde Default
3600
)
->addOption(
'dry-run',
@@ -40,6 +39,7 @@ class MeilisearchFilesCleanupCommand extends Command
protected function execute(InputInterface $input, OutputInterface $output): int
{
// wichtig für Contao 4.13 & 5.x
$this->framework->initialize();
$grace = max(0, (int) $input->getOption('grace'));
@@ -53,7 +53,7 @@ class MeilisearchFilesCleanupCommand extends Command
->cnt;
$output->writeln(sprintf(
'[DRY-RUN] %d stale file(s) would be removed (last_seen < %s)',
'<comment>[DRY-RUN]</comment> %d stale file(s) would be removed (last_seen < %s)',
$count,
date('Y-m-d H:i:s', $cutoff)
));
@@ -67,7 +67,7 @@ class MeilisearchFilesCleanupCommand extends Command
->affectedRows;
$output->writeln(sprintf(
'Removed %d stale file(s) from tl_search_pdf (last_seen < %s)',
'<info>Removed %d stale file(s)</info> (last_seen < %s)',
$affected,
date('Y-m-d H:i:s', $cutoff)
));