From: Vincent Vanwaelscappel Date: Wed, 22 Feb 2023 09:43:35 +0000 (+0100) Subject: wip #5524 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=3457d4528d8422abc87d57ceee92de607e2846e5;p=fluidbook-toolbox.git wip #5524 --- diff --git a/app/Fluidbook/Farm.php b/app/Fluidbook/Farm.php index ed73d0cc4..da1df597c 100644 --- a/app/Fluidbook/Farm.php +++ b/app/Fluidbook/Farm.php @@ -6,6 +6,7 @@ use Cubist\Util\Files\Files; use hollodotme\FastCGI\Client; use hollodotme\FastCGI\Requests\PostRequest; use hollodotme\FastCGI\SocketConnections\NetworkSocket; +use Illuminate\Support\Facades\Cache; class Farm { @@ -113,18 +114,30 @@ class Farm $hash = Files::hashFileAttributes($pdf); $out = Files::mkdir(protected_path('fluidbookpublication/cache/pdffiles/' . $hash)); } - $params = ['toolbox' => 1, - 'pdf' => $pdf, + + $attrs = ['pdf' => $pdf, 'page' => $page, 'format' => $format, 'resolution' => $resolution, 'withText' => $withText, 'withGraphics' => $withGraphics, 'version' => $version, - 'force' => $force, 'out' => $out]; - return self::_getFile($params); + + $cachekey = 'filefrompdf_' . hash('sha256', print_r($attrs, true)); + + $params = array_merge($attrs, ['toolbox' => 1, + 'force' => $force, + ]); + + if ($force) { + Cache::forget($cachekey); + } + + return Cache::rememberForever($cachekey, function () use ($params) { + return self::_getFile($params); + }); } protected static function _getFile($params) diff --git a/app/Jobs/FluidbookCompiler.php b/app/Jobs/FluidbookCompiler.php index f00ce985f..6bb9acfef 100644 --- a/app/Jobs/FluidbookCompiler.php +++ b/app/Jobs/FluidbookCompiler.php @@ -2951,7 +2951,8 @@ height="0" width="0" style="display:none;visibility:hidden"> , 'data/contents/p' . $page . '.svg'); } - $this->vdir->copy($this->getFluidbook()->getThumbFile($page, $this->imageFormat), 'data/thumbnails/p' . $page . '.' . $this->imageFormat); + $t=$this->getFluidbook()->getThumbFile($page, $this->imageFormat); + $this->vdir->copy($t, 'data/thumbnails/p' . $page . '.' . $this->imageFormat); $this->log('Made image page ' . $page); }