]> _ Git - odl.git/commitdiff
wip #4793 @0.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 15 Oct 2021 10:39:48 +0000 (12:39 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 15 Oct 2021 10:39:48 +0000 (12:39 +0200)
app/Jobs/ProcessFluidbook.php

index de9c5e6242ea9ee491767fb128622db0fd156580..6c01d3896d71b0c4b97bd61b96f5e902efc13ed4 100644 (file)
@@ -64,23 +64,29 @@ class ProcessFluidbook extends Compiler
         return $fname;
     }
 
+    /**
+     * @throws \Exception
+     */
     protected function _zipAssets($id)
     {
         /** @var Asset $asset */
         $asset = Asset::find($id);
         $collection = $asset->getMediaInField($asset->getAttributeValue('file_upload'));
         $tmp = Files::tmpdir();
-        $zip = Files::tempnam() . '.zip';
+        $zip = Files::tempnam($this->wdir) . '.zip';
 
         foreach ($collection as $item) {
             $path = $item->getPath();
-            $spl = new \SplFileInfo($path);
             /** @var $item Media */
-            copy($path, $tmp . $spl->getFilename());
+            $dest = $tmp . '/' . Files::getFilename($path);
+            copy($path, $dest);
         }
         Zip::archive($tmp, $zip);
+        if (!file_exists($zip)) {
+            throw new \Exception('Error while compressing assets of ' . $id . ' (' . $tmp . ')');
+        }
         Files::rmdir($tmp);
-        return $zip;
+        return Files::getFilename($zip);
     }