]> _ Git - fluidbook-toolbox.git/commitdiff
wip #5524
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 22 Feb 2023 09:43:35 +0000 (10:43 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 22 Feb 2023 09:43:35 +0000 (10:43 +0100)
app/Fluidbook/Farm.php
app/Jobs/FluidbookCompiler.php

index ed73d0cc48d818e832d63104214729cab4d7a71b..da1df597c88f342eb10b254cd30eee08cdd2795e 100644 (file)
@@ -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)
index f00ce985f0b3755972466f15d38f25881adeb63a..6bb9acfef34ad7e6a92756f31d77a0c247053de8 100644 (file)
@@ -2951,7 +2951,8 @@ height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
                     , '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);
         }