From 65cd40762e14da2264dbf9a8a362cd3c4846cb4a Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Thu, 15 Jan 2026 18:50:37 +0100 Subject: [PATCH] wip #7894 @0.25 --- src/CommandLine/Docling.php | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/CommandLine/Docling.php b/src/CommandLine/Docling.php index 73bebbc..839dd6e 100644 --- a/src/CommandLine/Docling.php +++ b/src/CommandLine/Docling.php @@ -19,8 +19,8 @@ class Docling extends CommandLine { $f = new \SplFileInfo($image); - $out = $image . '.' . md5($locale) . '.html'; - if (!file_exists($out) || filemtime($out) < filemtime($image) || filemtime($out) < filemtime(__FILE__)) { + $out = self::cache($image, $locale); + if (self::isCached($out, $locale)) { $tmp = Files::tmpdir(); $cli = new self(); $cli->setArg('to', 'md'); @@ -43,4 +43,15 @@ class Docling extends CommandLine return $html ?? file_get_contents($out); } } + + public static function cache($image, $locale = null) + { + return $image . '.' . md5($locale??'null') . '.html'; + } + + public static function isCached($image, $locale = null) + { + $out = self::cache($image, $locale); + return !(!file_exists($out) || filemtime($out) < filemtime($image) || filemtime($out) < filemtime(__FILE__)); + } } \ No newline at end of file -- 2.39.5