eeprom/cron.php

24 lines
670 B
PHP
Raw Normal View History

2020-05-08 22:53:21 +00:00
<?php
namespace EEPROM;
2024-12-23 00:52:14 +00:00
$cronPath = sys_get_temp_dir() . '/eeprom-cron-' . hash('sha256', __DIR__) . '.lock';
if(is_file($cronPath))
die('EEPROM cron script is already running.' . PHP_EOL);
2020-05-08 22:53:21 +00:00
2024-12-23 00:52:14 +00:00
touch($cronPath);
try {
require_once __DIR__ . '/eeprom.php';
2020-05-08 22:53:21 +00:00
2024-12-23 00:52:14 +00:00
$eeprom->uploadsCtx->uploadsData->deleteExpiredUploads();
2020-05-08 22:53:21 +00:00
2024-12-23 00:52:14 +00:00
$records = $eeprom->storageCtx->records->getFiles(orphaned: true);
foreach($records as $record)
$eeprom->storageCtx->deleteFile($record);
2023-11-09 20:29:57 +00:00
2024-12-23 00:52:14 +00:00
$records = $eeprom->storageCtx->records->getFiles(denied: true);
foreach($records as $record)
$eeprom->storageCtx->deleteFile($record);
} finally {
2024-12-23 00:52:14 +00:00
unlink($cronPath);
}