feat: 新增临时压缩下载文件24小时自动清理

This commit is contained in:
ganzizi
2023-11-17 11:56:22 +08:00
parent 14913ae312
commit 2737fa4697
3 changed files with 22 additions and 1 deletions

View File

@@ -96,6 +96,26 @@ class DeleteTmpTask extends AbstractTask
});
}
break;
/**
* file_pack 临时压缩下载文件
*/
case 'file_pack':
{
$path = storage_path('app/temp/download/');
$dirIterator = new \RecursiveDirectoryIterator($path);
$iterator = new \RecursiveIteratorIterator($dirIterator);
foreach ($iterator as $file) {
if ($file->isFile()) {
$time = $file->getMTime();
if ($time < time() - 3600 * 24) {
unlink($file->getPathname());
}
}
}
}
break;
}
}