fix caching

This commit is contained in:
Miraty 2024-09-05 20:51:24 +02:00
parent 40c53a7c30
commit aae5a9726d

View file

@ -122,12 +122,10 @@ foreach ($pages as $node) {
$lang = $files_langs[$src];
$file_timestamped = str_replace(SITE . 'cache/', SITE, $src);
if (!file_exists($file_timestamped)) {
foreach ($pages_langs[$path_parts_src['dirname'] . '/' . $page_names[$src]] as $page_lang) {
if (!file_exists($file_timestamped))
foreach ($pages_langs[$path_parts_src['dirname'] . '/' . $page_names[$src]] as $page_lang)
if (file_exists($file_timestamped = str_replace('.' . $lang . '.', '.' . $page_lang . '.', $file_timestamped)))
break;
}
}
$last_update = match (preg_match("/^(?<year>[0-9]{4})-(?<month>[0-9]{2})-(?<day>[0-9]{2})-/D", $path_parts_src['basename'], $date)) {
1 => (new DateTime())->setDate($date['year'], $date['month'], $date['day'])->format('U'),
0 => (new SplFileInfo($file_timestamped))->getMTime(),
@ -141,7 +139,7 @@ foreach ($pages as $node) {
preg_match('/^# (?<title>.*)$/Dm', $content, $matches);
$title = $matches['title'] ?? NULL;
if (!file_exists($base_filepath_target . '.html') OR (filemtime($src) > filemtime($base_filepath_target . '.html')) OR $opt['force']) {
if (!file_exists($base_filepath_target . '.html') OR (filemtime($file_timestamped) > filemtime($base_filepath_target . '.html')) OR $opt['force']) {
echo 'Compiling ' . $src . ' ' . date("Y-m-d H:i:s", $last_update) . LF;
// Execute PHP code