From: Vincent Vanwaelscappel Date: Thu, 15 Jan 2026 19:01:47 +0000 (+0100) Subject: #7894 @1.5 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=8caa7dfc95d4413a8aed26424fc3076fc40c3e0a;p=fluidbook-toolbox.git #7894 @1.5 --- diff --git a/app/Fluidbook/Compiler/Links.php b/app/Fluidbook/Compiler/Links.php index 7252b66dd..2d7c68959 100644 --- a/app/Fluidbook/Compiler/Links.php +++ b/app/Fluidbook/Compiler/Links.php @@ -557,7 +557,11 @@ trait Links } if ($returnJobs) { - $res[] = new OCR($file, $this->getFluidbook()->locale); + $j = new OCR($file, $this->getFluidbook()->locale); + if ($j->isOK()) { + continue; + } + $res[] = $j; } else { $res .= Farm::OCR($file, $this->getFluidbook()->locale); } diff --git a/app/Jobs/BaseStatus.php b/app/Jobs/BaseStatus.php index 25f05fa96..79355b1ef 100644 --- a/app/Jobs/BaseStatus.php +++ b/app/Jobs/BaseStatus.php @@ -11,16 +11,28 @@ abstract class BaseStatus extends Base public function setFinish($finish = true) { - Cache::put($this->_cacheKey(), $finish, 1200); + Cache::put($this->_cacheKey(), $finish, 3600); } - public function isFinish() { return Cache::get($this->_cacheKey(), false); } - public function isDone() + /** + * @return boolean + */ + public function isDone($forceCheck = false) + { + return $this->isFinish() || $this->isOK($forceCheck); + } + + public function isError() + { + return $this->isFinish() && !$this->isOK(); + } + + public function isOK($forceCheck = false) { return $this->isFinish(); } diff --git a/app/Jobs/FluidbookDocumentFileProcess.php b/app/Jobs/FluidbookDocumentFileProcess.php index 79abfb899..f4134492c 100644 --- a/app/Jobs/FluidbookDocumentFileProcess.php +++ b/app/Jobs/FluidbookDocumentFileProcess.php @@ -60,24 +60,12 @@ class FluidbookDocumentFileProcess extends BaseStatus return 'job_' . $this->path; } - /** - * @return boolean - */ - public function isDone($forceCheck = false) - { - return $this->isFinish() || $this->isOK($forceCheck); - } public function isOK($forceCheck = false) { return $this->document->hasFile($this->page, $this->format, $this->resolution, $this->quality, $this->withText, $this->withGraphics, $this->transparent, $this->version, $this->forceCheck || $forceCheck); } - public function isError() - { - return $this->isFinish() && !$this->isOK(); - } - /** * @return mixed|string */ diff --git a/app/Jobs/FluidbookImagesPreprocess.php b/app/Jobs/FluidbookImagesPreprocess.php index d039d8d83..9b8cb5fc3 100644 --- a/app/Jobs/FluidbookImagesPreprocess.php +++ b/app/Jobs/FluidbookImagesPreprocess.php @@ -66,20 +66,20 @@ class FluidbookImagesPreprocess extends Base $imdir = 'html'; } - for ($page = 1; $page <= $this->book->getPagesNumber(); $page++) { - $thisrasterize = in_array($page, $rasterizePages); - $thisimagesvg = !$thisrasterize && $svg; - $pageBackgroundsToGenerate = $thisrasterize ? [true] : $globalBackgroundToGenerate; - foreach ($resolutions as $r) { - foreach ($pageBackgroundsToGenerate as $withText) { - $this->getFile($page, $settings->imageFormat, $r, $withText, true, $transparent, $imdir); - } - } - if ($thisimagesvg) { - $this->getFile($page, 'svg', 150, true, in_array($page, $vectorPages), false, 'html'); - } - $this->getFile($page, $settings->imageFormat, 'thumb'); - } +// for ($page = 1; $page <= $this->book->getPagesNumber(); $page++) { +// $thisrasterize = in_array($page, $rasterizePages); +// $thisimagesvg = !$thisrasterize && $svg; +// $pageBackgroundsToGenerate = $thisrasterize ? [true] : $globalBackgroundToGenerate; +// foreach ($resolutions as $r) { +// foreach ($pageBackgroundsToGenerate as $withText) { +// $this->getFile($page, $settings->imageFormat, $r, $withText, true, $transparent, $imdir); +// } +// } +// if ($thisimagesvg) { +// $this->getFile($page, 'svg', 150, true, in_array($page, $vectorPages), false, 'html'); +// } +// $this->getFile($page, $settings->imageFormat, 'thumb'); +// } $this->book->getLinksAndRulers($links, $rulers); $compiler = new Compiler($this->book); @@ -93,7 +93,8 @@ class FluidbookImagesPreprocess extends Base if (!$jobs) { continue; } - $this->jobs += $jobs; + $this->jobs = array_merge($this->jobs, $jobs); + foreach ($jobs as $job) { if ($this->_sync) { $job->handle(); @@ -118,6 +119,7 @@ class FluidbookImagesPreprocess extends Base $done = 0; $error = 0; + foreach ($this->jobs as $job) { if ($job->isDone()) { $done++; diff --git a/app/Jobs/OCR.php b/app/Jobs/OCR.php index ffe713db4..90f7ce402 100644 --- a/app/Jobs/OCR.php +++ b/app/Jobs/OCR.php @@ -3,6 +3,7 @@ namespace App\Jobs; use App\Fluidbook\Farm; +use Cubist\Util\CommandLine\Docling; class OCR extends BaseStatus { @@ -19,11 +20,27 @@ class OCR extends BaseStatus public function handle() { Farm::OCR($this->file, $this->locale); - $this->setFinish(); + } + + public function isDone($forceCheck = false) + { + return $this->isOK($forceCheck); + } + + public function isOK($forceCheck = false) + { + return Docling::isCached($this->file, $this->locale); + } + + public function isFinish() + { + return false; } protected function _cacheKey(): string { - return 'job_ocr_' . $this->file . '_' . ($this->locale ?? ''); + $res= 'job_ocr_' . $this->file . '_' . ($this->locale ?? ''); + return $res; } + } diff --git a/composer.lock b/composer.lock index 4bd8bb6a5..e5c442101 100644 --- a/composer.lock +++ b/composer.lock @@ -108,16 +108,16 @@ }, { "name": "aws/aws-sdk-php", - "version": "3.369.12", + "version": "3.369.13", "source": { "type": "git", "url": "https://github.com/aws/aws-sdk-php.git", - "reference": "36ee8894743a254ae2650bad4968c874b76bc7de" + "reference": "bedc36250c92b8287be855a2d25427fb0e065483" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/36ee8894743a254ae2650bad4968c874b76bc7de", - "reference": "36ee8894743a254ae2650bad4968c874b76bc7de", + "url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/bedc36250c92b8287be855a2d25427fb0e065483", + "reference": "bedc36250c92b8287be855a2d25427fb0e065483", "shasum": "" }, "require": { @@ -199,9 +199,9 @@ "support": { "forum": "https://github.com/aws/aws-sdk-php/discussions", "issues": "https://github.com/aws/aws-sdk-php/issues", - "source": "https://github.com/aws/aws-sdk-php/tree/3.369.12" + "source": "https://github.com/aws/aws-sdk-php/tree/3.369.13" }, - "time": "2026-01-13T19:12:08+00:00" + "time": "2026-01-14T19:13:46+00:00" }, { "name": "backpack/backupmanager", @@ -2524,13 +2524,13 @@ "source": { "type": "git", "url": "git://git.cubedesigners.com/cubist_util.git", - "reference": "1c47b1f5be2cd335d034a64fe10000e59473241f" + "reference": "65cd40762e14da2264dbf9a8a362cd3c4846cb4a" }, "dist": { "type": "tar", - "url": "https://composer.cubedesigners.com/dist/cubist/util/cubist-util-dev-master-834a22.tar", - "reference": "1c47b1f5be2cd335d034a64fe10000e59473241f", - "shasum": "6b0e2cfc57d879e4114031ea3f019c179ab87ce6" + "url": "https://composer.cubedesigners.com/dist/cubist/util/cubist-util-dev-master-2e01d2.tar", + "reference": "65cd40762e14da2264dbf9a8a362cd3c4846cb4a", + "shasum": "a4c0d149a3ba22a2d929ba4cc785d2fbdfee00aa" }, "require": { "cubist/net": "dev-master", @@ -2564,7 +2564,7 @@ } ], "description": "Utilities class", - "time": "2026-01-14T18:00:53+00:00" + "time": "2026-01-15T17:50:37+00:00" }, { "name": "cviebrock/eloquent-sluggable", @@ -4131,13 +4131,13 @@ "source": { "type": "git", "url": "git://git.cubedesigners.com/fluidbook_tools.git", - "reference": "87006bd32ce4299a18924401eaa6c4b7a6bb26fa" + "reference": "86e6dfafcae904bf7a9e71e84785492a6331dc04" }, "dist": { "type": "tar", - "url": "https://composer.cubedesigners.com/dist/fluidbook/tools/fluidbook-tools-dev-master-af8ec1.tar", - "reference": "87006bd32ce4299a18924401eaa6c4b7a6bb26fa", - "shasum": "c9e07243c7a85d9bd00b1a2ee2810c8f4984b2fb" + "url": "https://composer.cubedesigners.com/dist/fluidbook/tools/fluidbook-tools-dev-master-ee535f.tar", + "reference": "86e6dfafcae904bf7a9e71e84785492a6331dc04", + "shasum": "e34ed35d3e10ac66d28537c9e04bfe07685cc29e" }, "require": { "barryvdh/laravel-debugbar": "*", @@ -4173,7 +4173,7 @@ } ], "description": "Fluidbook Tools", - "time": "2026-01-14T16:56:21+00:00" + "time": "2026-01-15T16:03:49+00:00" }, { "name": "fpdf/fpdf",