diff --git a/cron.php b/cron.php index 2fb2db0..c52470d 100644 --- a/cron.php +++ b/cron.php @@ -88,12 +88,15 @@ function run__cronjobs_cache_cleanup() { $cache_dir = $GLOBALS['appconf']['data_dir'].'/cache'; if (!file_exists($cache_dir)) return; + $others = []; foreach (scandir($cache_dir) as $fl) { if (in_array($fl, ['.','..'])) continue; $ps = explode(',',$fl); - if ($ps[1] !== 'ondemand') + if ($ps[1] !== 'ondemand') { + $others []= $fl; continue; + } $time = intval($ps[2]); $mtime = filemtime($cache_dir.'/'.$fl); if (time() - $mtime >= $time) { @@ -101,6 +104,26 @@ function run__cronjobs_cache_cleanup() { unlink($cache_dir.'/'.$fl); } } + $dir = $GLOBALS['appconf']['data_dir'].'/cron/db'; + foreach ($others as $fl) { + $ps = explode(',',$fl); + if (count($ps) === 2 && $ps[1] === 'always') { + $id = $ps[0]; + $contains = false; + foreach (scandir($dir) as $f) { + if (in_array($f, ['.','..'])) + continue; + if (strpos($f, ','.$id.',') !== false) { + $contains = true; + break; + } + } + if (!$contains) { + logi('CACHE-CLEANUP remove unused "always" cache: '.$fl); + unlink($cache_dir.'/'.$fl); + } + } + } } run__cronjobs_cache_cleanup(); //