This commit is contained in:
Your Name
2026-11-09 11:56:28 +08:00
parent 839166524f
commit 01a46ee06f
17 changed files with 1552 additions and 31 deletions
@@ -0,0 +1,32 @@
<?php
declare(strict_types=1);
namespace app\command;
use app\common\service\mobilerecording\MobileRecordingStorage;
use think\console\Command;
use think\console\Input;
use think\console\Output;
use think\console\input\Option;
final class MobileRecordingCleanup extends Command
{
protected function configure()
{
$this->setName('mobile-recording:cleanup')->setDescription('清理无数据库引用且超过一天的私有录音孤儿文件')
->addOption('dry-run', null, Option::VALUE_NONE, '只统计,不删除');
}
protected function execute(Input $input, Output $output): int
{
try {
$result = MobileRecordingStorage::cleanupOrphans((bool) $input->getOption('dry-run'));
$output->writeln('MOBILE_RECORDING_CLEANUP ' . json_encode($result));
return $result['errors'] > 0 ? 1 : 0;
} catch (\Throwable $e) {
$output->writeln('MOBILE_RECORDING_CLEANUP storage_or_configuration_error');
return 1;
}
}
}