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

29 lines
778 B
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);
require_once __DIR__ . '/eeprom.php';
// Mark expired as deleted
$expired = Upload::expired($db);
foreach($expired as $upload)
$upload->delete($db, false);
// Hard delete soft deleted files
$deleted = Upload::deleted($db);
foreach($deleted as $upload)
$upload->delete($db, true);
sem_release($semaphore);