From: vincent@cubedesigners.com Date: Fri, 16 Oct 2020 09:43:53 +0000 (+0000) Subject: wait #3955 @1.5 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=02ce490bc98fec94d01c46990652868c2a4689c8;p=cubeextranet.git wait #3955 @1.5 --- diff --git a/inc/ws/Metier/class.ws.document.php b/inc/ws/Metier/class.ws.document.php index 44faa63ed..c16eb74db 100644 --- a/inc/ws/Metier/class.ws.document.php +++ b/inc/ws/Metier/class.ws.document.php @@ -126,6 +126,10 @@ class wsDocument extends cubeMetier $in = $this->in; } + if (!$force && file_exists($this->infos)) { + return; + } + $fwstk = new cubeCommandLine('fwstk.sh'); $fwstk->setPath(CONVERTER_PATH); $fwstk->setArg('--input ' . $in); @@ -397,6 +401,7 @@ class wsDocument extends cubeMetier $dir = rtrim($this->out . $version, '/') . '/'; + $minsize = 1; if ($format === 'svg') { $prefix = $withGraphics ? 'f' : 't'; $file = $dir . $prefix . 'o' . $page; @@ -404,22 +409,46 @@ class wsDocument extends cubeMetier $file .= '-' . $resolution; } $file .= '.svg'; + $reffile = $this->makeSVGFile($page); + $minsize = 100; } else if ($format === 'png' || $format === 'jpg') { $prefix = $withText ? 't' : 'h'; if ($resolution === 'thumb') { $file = $dir . 'p' . $page . '.' . $format; } else { $file = $dir . $prefix . $page . '-' . $resolution . '.' . $format; + $alt = $dir . $prefix . $resolution . '-' . $page . '.' . $format; } } + + $do = false; if (!file_exists($file)) { + if (isset($alt) && file_exists($alt)) { + rename($alt, $file); + $do = false; + } else { + $do = true; + } + } else if (filesize($file) < $minsize) { + $do = true; + } else if (isset($reffile) && filemtime($file) < filemtime($reffile)) { + $do = true; + } + + if ($do) { $this->makeFile($file, $page, $format, $resolution, $withText, $withGraphics, $version); } return $file; } - public function makeFile($file, $page, $format = 'jpg', $resolution = 150, $withText = true, $withGraphics = true) + public function makeFile($file, $page, $format = 'jpg', $resolution = 150, $withText = true, $withGraphics = true, $version = 'html') { + $lock = $file . '.lock'; + if (file_exists($lock) && filemtime($lock) > time() - 300) { + sleep(10); + return $this->getFile($page, $format, $resolution, $withText, $withGraphics, $version); + } + touch($lock); if ($format === 'jpeg') { $format = 'jpg'; } @@ -433,10 +462,11 @@ class wsDocument extends cubeMetier if ($resolution === 'thumb') { wsPDFConvert::makeMiniShot($this->getSplittedPDFPage($page), $file, 1, $format); } else { - $rr = version === 'html' ? $this->getResolutionRatio() : $this->getMobileFirstRatio(); + $rr = $version === 'html' ? $this->getResolutionRatio() : $this->getMobileFirstRatio(); wsPDFConvert::makeShotPNM($this->getSplittedPDFPage($page), $file, 1, '', $resolution * $rr, 85, 4, $withText, null, null, $format); } } + unlink($lock); } public function cutDocument($mode) @@ -539,7 +569,7 @@ class wsDocument extends cubeMetier { $svgFile = $this->out . '/html/fp' . $page . '.svg'; if (!$force && file_exists($svgFile) && filesize($svgFile) > 0) { - return; + return $svgFile; } wsPDFConvert::makeBaseSVGFile($this->getSplittedPDFPage($page), $svgFile, 1); return $svgFile; @@ -548,10 +578,6 @@ class wsDocument extends cubeMetier public function makeTextSVGFile($page, $out, $force = false) { $in = $this->makeSVGFile($page); - $do = $force || !file_exists($out) || filesize($out) < 100 || filemtime($in) > filemtime($out) || filemtime($out) < filemtime(__FILE__); - if (!$do) { - return; - } wsPDFConvert::makeTextSVGFile($in, $out); wsTools::optimizeSVG($out, $out); } diff --git a/inc/ws/Util/class.ws.pdf.convert.php b/inc/ws/Util/class.ws.pdf.convert.php index 4749d2ce2..c88871bd9 100644 --- a/inc/ws/Util/class.ws.pdf.convert.php +++ b/inc/ws/Util/class.ws.pdf.convert.php @@ -105,7 +105,7 @@ class wsPDFConvert { // Fabrication des thumbanails avec ghostscript - $gs = new cubeCommandLine('gs', null, true); + $gs = new CubeIT_CommandLine('gs', null, true); $gs->setPath(CONVERTER_PATH); $gs->setEnv('GS_FONTPATH', FONT_PATH); $gs->setArg('-dBATCH'); @@ -146,7 +146,7 @@ class wsPDFConvert $antialiasing = $antialiasing ? 'yes' : 'no'; $freetype = $texts ? 'yes' : 'no'; // Exporte les fichiers - $pdftoppm = new cubeCommandLine('/usr/local/bin/pdftoppm', null, true); + $pdftoppm = new CubeIT_CommandLine('/usr/local/bin/pdftoppm', null, true); $pdftoppm->setPath(CONVERTER_PATH); $pdftoppm->setArg('f', $page);