2
0
Fork 0
forked from flashii/eeprom
eeprom-nabucco/cron.php

42 lines
1.3 KiB
PHP
Raw Normal View History

2020-05-08 22:53:21 +00:00
<?php
namespace EEPROM;
if(!defined('EEPROM_SEM_NAME'))
define('EEPROM_SEM_NAME', 'c');
if(!defined('EEPROM_SFM_PATH'))
define('EEPROM_SFM_PATH', sys_get_temp_dir() . DIRECTORY_SEPARATOR . '{6bf19abb-ae7e-4a1d-85f9-00dfb7c90264}');
if(!is_file(EEPROM_SFM_PATH))
touch(EEPROM_SFM_PATH);
$ftok = ftok(EEPROM_SFM_PATH, EEPROM_SEM_NAME);
$semaphore = sem_get($ftok, 1);
if(!sem_acquire($semaphore))
die('Failed to acquire semaphore.' . PHP_EOL);
try {
require_once __DIR__ . '/eeprom.php';
2020-05-08 22:53:21 +00:00
$uploadsCtx = $eeprom->getUploadsContext();
$uploadsData = $uploadsCtx->getUploadsData();
2020-05-08 22:53:21 +00:00
// Mark expired as deleted
$expired = $uploadsData->getUploads(expired: true, deleted: false, dmca: false);
foreach($expired as $uploadInfo)
$uploadsData->deleteUpload($uploadInfo);
2020-05-08 22:53:21 +00:00
// Hard delete soft deleted files
$deleted = $uploadsData->getUploads(deleted: true, dmca: false);
foreach($deleted as $uploadInfo) {
$uploadsCtx->deleteUploadData($uploadInfo);
$uploadsData->nukeUpload($uploadInfo);
}
2023-11-09 20:29:57 +00:00
// Ensure local data of DMCA'd files is gone
$deleted = $uploadsData->getUploads(dmca: true);
foreach($deleted as $uploadInfo)
$uploadsCtx->deleteUploadData($uploadInfo);
} finally {
sem_release($semaphore);
}