use Cubist\Util\Gzip;
use Cubist\Util\Math;
use Illuminate\Support\Facades\Cache;
+use Illuminate\Support\Facades\Log;
// __('!!Paramètres des fluidbooks')
class FluidbookDocument extends ToolboxModel
['svg', 150, true, false, 'html'],
];
+ Log::debug('Sync ? ' . $sync);
+
$nbfiles = count($files);
for ($i = 1; $i <= $this->pages; $i++) {
foreach ($files as $file) {
} else {
dispatch($job);
}
+
$jobs[] = $job;
- $this->_checkJobs($uploadID, $jobs, $nbfiles);
+ if ($sync) {
+ $this->_checkJobs($uploadID, $jobs, $nbfiles, true);
+ }
}
+
+ if (!$sync && $i % 4 === 0) {
+ $this->_checkJobs($uploadID, $jobs, $nbfiles, false);
+ }
+
}
while (true) {
- if ($this->_checkJobs($uploadID, $jobs, $nbfiles) === 1) {
+ if ($this->_checkJobs($uploadID, $jobs, $nbfiles, true) === 1) {
return;
}
usleep(0.25 * 1000000);
Farm::extractLinks($this->getPDFSource(), $this->path());
}
- protected function _checkJobs($uploadID, $jobs, $nbfiles)
+ protected function _checkJobs($uploadID, $jobs, $nbfiles, $checkFile = true)
{
$this->checkInfos();
$nbjobs = $nbfiles * $this->pages;
$done = 0;
foreach ($jobs as $job) {
/** @var $job FluidbookDocumentFileProcess */
- if ($job->isDone()) {
+ if ($job->isDone(false, $checkFile)) {
$done++;
}
}
public function checkInfos($force = false)
{
if ($force || null === $this->pdf_data) {
+ Log::debug('check document infos');
$infos = $this->_getInfos();
$this->pages = $infos->pages;
public function _getPath($page, $format = 'jpg', $resolution = 150, $quality = 85, $withText = true, $withGraphics = true, $version = 'html')
{
$this->_normalize($format, $resolution, $quality, $withText, $withGraphics, $version);
- $cacheKey = $this->fileCacheKey($page, $format, $resolution, $quality, $withText, $withGraphics, $version);
- if (Cache::has($cacheKey)) {
- return Cache::get($cacheKey);
- }
+ $cacheKey = $this->fileCacheKey($page, $format, $resolution, $quality, $withText, $withGraphics, $version) . '_path';
- $dir = $this->path($version) . '/';
+ return Cache::rememberForever($cacheKey, function () use ($page, $format, $resolution, $quality, $withText, $withGraphics, $version) {
+ $dir = $this->path($version) . '/';
- if ($format === 'svg') {
- $prefix = $withGraphics ? 'f' : 't';
- $file = $dir . $prefix . 'o' . $page;
- if ($withGraphics) {
- $file .= '-' . $resolution;
- }
- $file .= '.svg';
- } else {
- $q = ($format === 'jpg' && $quality != 85) ? '-' . $quality : '';
- $prefix = $withText ? 't' : 'h';
- if ($resolution === 'thumb') {
- $file = $dir . 'p' . $page . $q . '.' . $format;
+ if ($format === 'svg') {
+ $prefix = $withGraphics ? 'f' : 't';
+ $file = $dir . $prefix . 'o' . $page;
+ if ($withGraphics) {
+ $file .= '-' . $resolution;
+ }
+ $file .= '.svg';
} else {
- $file = $dir . $prefix . $page . '-' . $resolution . $q . '.' . $format;
+ $q = ($format === 'jpg' && $quality != 85) ? '-' . $quality : '';
+ $prefix = $withText ? 't' : 'h';
+ if ($resolution === 'thumb') {
+ $file = $dir . 'p' . $page . $q . '.' . $format;
+ } else {
+ $file = $dir . $prefix . $page . '-' . $resolution . $q . '.' . $format;
+ }
}
- }
- return $file;
+ return $file;
+ });
}
protected function fileCacheKey($page, $format = 'jpg', $resolution = 150, $quality = 85, $withText = true, $withGraphics = true, $version = 'html')