35 lines
1.1 KiB
PHP
35 lines
1.1 KiB
PHP
<?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';
|
|
|
|
// Mark expired as deleted
|
|
$expired = $eeprom->uploadsCtx->uploadsData->getUploads(expired: true, deleted: false);
|
|
foreach($expired as $uploadInfo)
|
|
$eeprom->uploadsCtx->uploadsData->deleteUpload($uploadInfo);
|
|
|
|
// Hard delete soft deleted files
|
|
$deleted = $eeprom->uploadsCtx->uploadsData->getUploads(deleted: true);
|
|
foreach($deleted as $uploadInfo) {
|
|
$eeprom->uploadsCtx->deleteUploadData($uploadInfo);
|
|
$eeprom->uploadsCtx->uploadsData->nukeUpload($uploadInfo);
|
|
}
|
|
|
|
// new storage format should store by hashes again, ensure blacklisted data is no longer saved
|
|
} finally {
|
|
sem_release($semaphore);
|
|
}
|