]> _ Git - fluidbook-toolbox.git/commitdiff
wip #5742 @0.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 17 Feb 2023 12:34:40 +0000 (13:34 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 17 Feb 2023 12:34:40 +0000 (13:34 +0100)
.docker/docker-compose.yml
app/Jobs/FluidbookCompiler.php

index 4699a24d3dd6a4e5ced898eeb922416154d3f1fc..d69616acc9f1f625c44209d6d61e4c52b70dc2f4 100644 (file)
@@ -15,6 +15,7 @@ services:
       - '/mnt/sshfs/godzilla/data/fluidbook/docs/:/application/protected/fluidbookpublication/docs/'
       - '/data/extranet/www/fluidbook/books/working/:/application/protected/fluidbookpublication/working/'
       - '/data/extranet/www/fluidbook/books/links/:/application/protected/fluidbookpublication/links/'
+      - '/home/extranet/www/fluidbook/cache/unzip/:/application/storage/fluidbook/cache/unzip/'
       - '/home/extranet:/home/extranet'
       - '/data/extranet:/data/extranet'
       - '/mnt:/mnt'
@@ -78,6 +79,7 @@ services:
       - '/mnt/sshfs/godzilla/data/fluidbook/docs/:/application/protected/fluidbookpublication/docs/'
       - '/data/extranet/www/fluidbook/books/working/:/application/protected/fluidbookpublication/working/'
       - '/data/extranet/www/fluidbook/books/links/:/application/protected/fluidbookpublication/links/'
+      - '/data/extranet/www/fluidbook/cache/unzip/:/application/storage/fluidbook/cache/unzip/'
       - '/home/extranet:/home/extranet'
       - '/data/extranet:/data/extranet'
       - '/mnt:/mnt'
index 5af7cf59307078b1ad279429d1487f5341211276..46843d9edbf9e58995015a9f611019ecb717e3fa 100644 (file)
@@ -31,6 +31,7 @@ use Cubist\Util\PHP;
 use Cubist\Util\Text;
 use Cubist\Util\Url;
 use Cubist\Util\WebVideo;
+use Cubist\Util\Zip;
 use DOMDocument;
 use DOMElement;
 use DOMXPath;
@@ -2528,11 +2529,11 @@ height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
     {
         Log::error($e);
 
-        $c=explode('\\',get_class($link));
-        $type=array_pop($c);
-        $type=str_replace('Link','',$type);
+        $c = explode('\\', get_class($link));
+        $type = array_pop($c);
+        $type = str_replace('Link', '', $type);
 
-        throw new \Exception('Error on the '.$type.' link to ' . $link->to . ' on page ' . $link->page . '  with message : ' . $e->getMessage());
+        throw new \Exception('Error on the ' . $type . ' link to ' . $link->to . ' on page ' . $link->page . '  with message : ' . $e->getMessage());
     }
 
     protected function _htmlLinkList($list)
@@ -3662,24 +3663,18 @@ height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
 
     public function unzipFile($file, $moveAssets = false, $baseDir = null)
     {
-        $fdir = is_null($baseDir) ? 'data/links/' . str_replace('.', '_', $file) : $baseDir;
+        $fdir = is_null($baseDir) ? 'data/links/' . str_replace('.', '_', $file) : commonTools::fixpath($baseDir);
+
+        $zipPath = $this->wdir . '/' . $file;
+        $dir = storage_path('fluidbook/cache/unzip') . Files::hashFileAttributes($zipPath);
 
-        $tmp = Files::tmpdir();
-        $dir = $tmp . '/' . $fdir;
-        if (file_exists($dir) && is_file($dir)) {
-            unlink($dir);
-        }
         if (!file_exists($dir)) {
             mkdir($dir, 0777, true);
-        }
-        $unzip = new CommandLine('unzip');
-        $unzip->setArg(null, $this->wdir . '/' . $file);
-        $unzip->setArg('d', $dir);
-        $unzip->execute();
-
-        if ($moveAssets) {
-            `mv $dir/Assets/* $dir`;
-            rmdir($dir . '/Assets');
+            Zip::extract($zipPath, $dir);
+            if ($moveAssets) {
+                `mv $dir/Assets/* $dir`;
+                rmdir($dir . '/Assets');
+            }
         }
 
         return array('dir' => $dir, 'fdir' => $fdir);
@@ -3713,8 +3708,7 @@ height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
         } else {
             $r = array('html' => false, 'inject' => array(file_get_contents($d . '/init.js')), 'injectcss' => array('multimedia.css'), 'injectjs' => array('multimedia.js'));
         }
-        $res = array_merge($res, $r);
-        return $res;
+        return array_merge($res, $r);
     }
 
     public function addFontKit($font)