]> _ Git - cubeextranet.git/commitdiff
wip #3655 @6
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Fri, 22 May 2020 17:44:45 +0000 (17:44 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Fri, 22 May 2020 17:44:45 +0000 (17:44 +0000)
inc/ws/Controlleur/class.ws.maintenance.php
inc/ws/Util/class.ws.links.php

index 9aa50bdb1362d2691822cc659e5bcc5d1fc8ad0f..64dc11c41248e9835e3c9a185989cee23456f934 100644 (file)
@@ -1737,19 +1737,22 @@ class wsMaintenance
         }
     }
 
-    public static function moveLinksToFiles()
+    public static function moveLinksToFiles($args)
     {
         CubeIT_Util_PHP::neverStop();
 
         global $core;
-        $r = $core->con->select('SELECT * FROM books');
+        $r = $core->con->select('SELECT * FROM books ORDER BY  book_id DESC');
+
+        $k = (int)$args[0];
 
         $books = [];
         while ($r->fetch()) {
-            $books[] = $r->book_id;
+            if ($r->book_id % 8 === $k) {
+                $books[] = $r->book_id;
+            }
         }
 
-
         foreach ($books as $id) {
             $dir = WS_BOOKS . '/links/' . $id;
             if (!file_exists($dir)) {
@@ -1760,9 +1763,10 @@ class wsMaintenance
             $updates = $dao->getLinksVersions($id);
 
             foreach ($updates as $time => $update) {
-                $file = $dir . '/' . $time . '.json.gz';
-                $meta = $dir . '/' . $time . '.meta.json.gz';
-                if (file_exists($file)) {
+                $file = $dir . '/' . $time . '.links';
+                $gzfile = $file . '.gz';
+                $meta = $dir . '/' . $time . '.meta';
+                if (file_exists($file) || file_exists($gzfile)) {
                     continue;
                 }
 
@@ -1772,13 +1776,8 @@ class wsMaintenance
                 wsLinks::getLinksAndRulers($id, $links, $rulers, $time);
 
                 $res = ['links' => $links, 'rulers' => $rulers];
-                $gz = gzopen($file, 'ab');
-                gzwrite($gz, json_encode($res));
-                gzclose($gz);
-
-                $gz = gzopen($meta, 'ab');
-                gzwrite($gz, json_encode($update));
-                gzclose($gz);
+                file_put_contents($file, json_encode($res));
+                file_put_contents($meta, json_encode($update));
             }
         }
     }
index e2d2650c2a068117e75d8ebb3dad9071b3fe3381..efa47bf6f88f6bfd9464354c51613352622a0790 100644 (file)
@@ -208,7 +208,6 @@ class wsLinks
 
     public static function getLinksAndRulers($book_id, &$links, &$rulers, $time = null)
     {
-
         global $core;
 
         $daoBook = new wsDAOBook($core->con);