]> _ Git - cubeextranet.git/commitdiff
wip #4563 @0.5
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Tue, 29 Jun 2021 09:55:37 +0000 (09:55 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Tue, 29 Jun 2021 09:55:37 +0000 (09:55 +0000)
inc/commons/_common.php
inc/ws/Controlleur/class.ws.maintenance.php
inc/ws/DAO/class.ws.dao.book.php

index 063410d4c7e5e315abea4d77f54fd4aa3def94c1..19014e74c6f27af6df83697072c656c569839d99 100644 (file)
@@ -17,5 +17,3 @@ $core->monitoring=true;
 $core->url->registerDefault(array('commonUrl', 'hub'));\r
 $core->url->register('ajax', 'ajax', '^ajax(.*)$', array('cubeAjax', 'ajax'));\r
 $core->url->register('tools', 'tools', '^tools(.*)$', array('commonTools', 'hub'));\r
-\r
-?>
\ No newline at end of file
index f0c2f65e1e509fdcfb199b470f31a74c46a38323..64d48e268b69ce2aebc81ef1e76b4309c95160db 100644 (file)
@@ -1505,6 +1505,11 @@ class wsMaintenance
         exit;
     }
 
+    public static function clearLocks(){
+        $dir=WS_BOOKS.'/locks/*';
+        `rm $dir`;
+    }
+
     public static function processPage($args)
     {
         CubeIT_Util_PHP::neverStop();
index 74bef09bdcd2d25596b53029fd5335b0b9b65969..d053c1233cd60b1f7f22fdaadd145b5f7c32a5bd 100644 (file)
@@ -8,6 +8,8 @@ class wsDAOBook extends commonDAO
     /** @var wsHTML5Compiler */
     public static $lastHTML5Compiler = null;
 
+    protected $_compileLock = null;
+
     /**
      * wsDAOBook::singleton()
      *
@@ -1191,17 +1193,19 @@ class wsDAOBook extends commonDAO
 
     public function compile($book_id, $version = 'all', $complete = false, $force = false, $dev = false, $book = null, $delete = true)
     {
+
         if (is_null($book_id) || !$book_id) {
             return;
         }
 
-        $compileLock = WS_BOOKS . '/locks/' . $book_id . '.lock';
+        $this->_compileLock = WS_BOOKS . '/locks/' . $book_id . '.lock';
+
 
-        while (file_exists($compileLock) && filemtime($compileLock) > time() - 3600) {
+        while (file_exists($this->_compileLock) && filemtime($this->_compileLock) > (time() - 900)) {
             sleep(10);
         }
         cubePHP::neverStop();
-        touch($compileLock);
+        touch($this->_compileLock);
 
         if (null === $book) {
             $book = $this->selectById($book_id);
@@ -1209,11 +1213,15 @@ class wsDAOBook extends commonDAO
         $pages = $this->getPagesOfBook($book_id);
 
         $res = '';
-        $this->compilePDF($book, $pages);
-        $res .= $this->compileHTML5($book_id, $book, $dev, $delete);
-        $this->touchCompile($book_id, 'html5');
+        try {
+            $this->compilePDF($book, $pages);
+            $res .= $this->compileHTML5($book_id, $book, $dev, $delete);
+            $this->touchCompile($book_id, 'html5');
+        } catch (Exception $e) {
+
+        }
 
-        unlink($compileLock);
+        unlink($this->_compileLock);
 
         return $res;
     }
@@ -1296,4 +1304,12 @@ class wsDAOBook extends commonDAO
         return $str;
     }
 
+    public function __destruct()
+    {
+        if (null !== $this->_compileLock && file_exists($this->_compileLock)) {
+            unlink($this->_compileLock);
+            $this->_compileLock = null;
+        }
+    }
+
 }