From: Vincent Vanwaelscappel Date: Fri, 31 Mar 2023 15:49:25 +0000 (+0200) Subject: wait #5611 @5 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=b8ffb896a68677b9cb06f8cb46a7cab34423d5ce;p=fluidbook-toolbox.git wait #5611 @5 --- diff --git a/.docker/config/supervisor/ws2-worker.conf b/.docker/config/supervisor/ws2-worker.conf index d5d556ebf..4b238f8d4 100644 --- a/.docker/config/supervisor/ws2-worker.conf +++ b/.docker/config/supervisor/ws2-worker.conf @@ -5,7 +5,7 @@ autostart=true autorestart=true user=toolbox group=www-data -numprocs=4 +numprocs=12 redirect_stderr=true stdout_logfile=/proc/self/fd/2 stopwaitsecs=3600 diff --git a/app/Fluidbook/Links.php b/app/Fluidbook/Links.php index 9236e3d9a..b7a601dec 100644 --- a/app/Fluidbook/Links.php +++ b/app/Fluidbook/Links.php @@ -136,7 +136,7 @@ class Links } - public static function getLinksAndRulers($book_id, &$links, &$rulers, $time = 'latest') + public static function getLinksAndRulers($book_id, &$links, &$rulers, $time = 'latest',$forceDecrypt=false) { if (null === $time) { $time = 'latest'; @@ -176,7 +176,7 @@ class Links $links = self::_UID($r['links']); $rulers = self::_UID($r['rulers']); - if (can('fluidbook-publication:links:edit-animations')) { + if ($forceDecrypt || can('fluidbook-publication:links:edit-animations')) { $links = Link::decryptLinks($links); } else { $links = Link::encryptLinks($links); diff --git a/app/Fluidbook/Packager/Download.php b/app/Fluidbook/Packager/Download.php index dd0cbca95..54099c86f 100644 --- a/app/Fluidbook/Packager/Download.php +++ b/app/Fluidbook/Packager/Download.php @@ -6,6 +6,8 @@ use App\Jobs\DownloadBase; use App\Models\FluidbookExternalInstallServer; use App\Services\ScormCloud; use Cubist\Backpack\Facades\App; +use Cubist\Backpack\Magic\Models\ExternalServer; +use Cubist\Net\Transfer\Driver; use Cubist\Util\CommandLine\Rsync; use Cubist\Util\Files\Files; use Cubist\Util\Text; @@ -99,7 +101,7 @@ class Download extends DownloadBase } } else if ($this->action === 'install') { $s = $this->entry->install_online; - $dest = self::_cleanInstallDir($s['path']); + $dest = Driver::cleanInstallDir($s['path']); /** @var FluidbookExternalInstallServer $server */ $server = FluidbookExternalInstallServer::find($s['server']); if (!$server) { @@ -134,13 +136,6 @@ class Download extends DownloadBase $this->sendNotification($subject, $text, $actions, $showTextIfNotEmail); } - protected static function _cleanInstallDir($path) - { - $path = str_replace('/\.{2,}/', '', $path); - $path = preg_replace('/\/{2,}/', '/', $path); - $path = trim($path, '/'); - return Text::str2URL($path, '-', true); - } protected function _compileandpackage($zip = true) { diff --git a/app/Jobs/FluidbookCollectionDownload.php b/app/Jobs/FluidbookCollectionDownload.php index 281fb602d..341de97a4 100644 --- a/app/Jobs/FluidbookCollectionDownload.php +++ b/app/Jobs/FluidbookCollectionDownload.php @@ -4,8 +4,10 @@ namespace App\Jobs; use App\Console\Commands\WorkshopMigration; use App\Fluidbook\Packager\Packager; +use App\Models\FluidbookExternalInstallServer; use App\Models\FluidbookPublication; use Cubist\Backpack\Magic\PageData; +use Cubist\Net\Transfer\Driver; use Cubist\Util\CommandLine\Rsync; use Cubist\Util\Files\Files; use Cubist\Util\PHP; @@ -26,16 +28,35 @@ class FluidbookCollectionDownload extends DownloadBase { $translateVariables = $this->_getTranslateVariables(); if ($this->action === 'install') { - $url = $this->installHosting($this->entry->getPageData()); - $this->sendNotification(__('Collection ":title" (#:nb) installée sur le serveur hosting', $translateVariables), '', $url); + $s = $this->entry->install; + $dest = Driver::cleanInstallDir($s['path']); + /** @var FluidbookExternalInstallServer $server */ + $server = FluidbookExternalInstallServer::find($s['server']); + if (!$server) { + throw new \Exception('No valid server defined for external installation'); + } + if (!$dest) { + throw new \Exception('No path defined for external server installation'); + } + + $translateVariables['server'] = $server->name; + $url = $this->install($dest, $server); + $this->sendNotification(__('Collection ":title" (#:nb) installée sur le serveur :server', $translateVariables), __('La collection ":title" a été installée sur le serveur :server', $translateVariables), [__('Voir sur :server', $translateVariables) => $url]); } else if ($this->action === 'export' && in_array($this->entry->version, ['win_inss_html', 'win_ins_html'])) { $url = $this->downloadList($this->entry->getPageData()); - $this->sendNotification(__($this->_subject, $translateVariables), __($this->_text, $translateVariables), $url); + $this->sendNotification(__($this->_subject, $translateVariables), __($this->_text, $translateVariables), [__('Télécharger') => $url]); } else { parent::handle(); } } + public function install($dest, $server) + { + $path = $this->_compile(); + $driver = $server->getTransferDriver(); + $driver->copy($path, $dest, false, false); + return $server->makeURL($dest); + } protected function _compile() { @@ -46,7 +67,7 @@ class FluidbookCollectionDownload extends DownloadBase /** * @param $path - * @return null + * @return void * @throws \Exception */ public function compile($path) @@ -56,13 +77,12 @@ class FluidbookCollectionDownload extends DownloadBase PHP::neverStop(); if ($data->type === 'scorm_multilang') { - $res = $this->compileMultilang($data, $path, true); + $this->compileMultilang($data, $path, true); } else if ($data->type === 'export_multilang') { - $res = $this->compileMultilang($data, $path, false); + $this->compileMultilang($data, $path, false); } elseif ($data->type === 'export') { - $res = $this->compileExport($data, $path); + $this->compileExport($data, $path); } - return $res; } protected function getCollectionGlobalSettings() @@ -89,7 +109,7 @@ class FluidbookCollectionDownload extends DownloadBase $langs = []; $countries = []; - $defaultFlags = ['en' => 'gb', 'sv' => 'se']; + $defaultFlags = ['en' => 'gb', 'sv' => 'se', 'zh' => 'cn']; $fluidbooks = []; @@ -127,7 +147,7 @@ class FluidbookCollectionDownload extends DownloadBase $jobs = []; foreach ($fluidbooks as $fbid => $publication) { - $jobs[] = $this->_jobDownloadFluidbook($fbid, $scorm ? 'scorm' : $data->version, $path . $langs[$fbid], $options); + $jobs[] = $this->_jobDownloadFluidbook($fbid, $scorm ? 'scorm' : 'online', $path . $langs[$fbid], $options); } $this->_waitJobs($jobs); @@ -211,11 +231,13 @@ class FluidbookCollectionDownload extends DownloadBase $job->setBookId($id); $job->setVersion($version); $job->setOptions($options); - $job->setAction('export'); $job->setJobName('export_' . $id); $job->setDestination($dest); - $f = $async ? 'dispatch' : 'dispatchSync'; - $f($job)->onQueue('ws2'); + if ($async) { + dispatch($job)->onQueue('ws2'); + } else { + $job->handle(); + } return $job; } @@ -238,7 +260,7 @@ class FluidbookCollectionDownload extends DownloadBase { $nbjobs = count($jobs); $done = 0; - foreach ($jobs as $label => $job) { + foreach ($jobs as $job) { if ($job->isDone()) { $done++; } diff --git a/app/Jobs/FluidbookCompiler.php b/app/Jobs/FluidbookCompiler.php index 1399ea484..19a08dbb4 100644 --- a/app/Jobs/FluidbookCompiler.php +++ b/app/Jobs/FluidbookCompiler.php @@ -671,7 +671,7 @@ class FluidbookCompiler extends Base implements CompilerInterface $file = $cdir . $this->fluidbookSettings->basketReferences; $this->config->basketReferences = ExcelToArray::excelToArrayKeyVars($file); - Links::getLinksAndRulers($this->book_id, $links, $rulers); + $this->getLinksAndRulers($links,$rulers); foreach ($links as $link) { if ($link['type'] == '12') { @@ -685,6 +685,10 @@ class FluidbookCompiler extends Base implements CompilerInterface } } + public function getLinksAndRulers(&$links, &$rulers){ + Links::getLinksAndRulers($this->book_id, $links, $rulers,'latest',true); + } + public function writeMIFCart() { $this->lessVariables['import-cart-styles'] = 'mif'; @@ -702,7 +706,7 @@ class FluidbookCompiler extends Base implements CompilerInterface $file = $cdir . $this->fluidbookSettings->basketReferences; $this->config->basketReferences = ExcelToArray::excelToArrayKeyVars($file); - Links::getLinksAndRulers($this->book_id, $links, $rulers); + $this->getLinksAndRulers($links, $rulers); foreach ($this->config->basketReferences as $ref => $data) { $source = $cdir . '/' . $data['Image']; @@ -784,7 +788,7 @@ class FluidbookCompiler extends Base implements CompilerInterface $this->vdir->copy($cdir . $f, 'data/commerce/' . $f); } - Links::getLinksAndRulers($this->book_id, $links, $rulers); + $this->getLinksAndRulers($links, $rulers); } public function writeGrandPavoisCart() @@ -804,7 +808,7 @@ class FluidbookCompiler extends Base implements CompilerInterface $file = $cdir . $this->fluidbookSettings->basketReferences; $this->config->basketReferences = ExcelToArray::excelToArrayKeyVars($file); - Links::getLinksAndRulers($this->book_id, $links, $rulers); + $this->getLinksAndRulers($links, $rulers); } @@ -825,7 +829,7 @@ class FluidbookCompiler extends Base implements CompilerInterface $this->config->eanReferences = ExcelToArray::excelToArrayIndexKeyVars($eanFile); } - Links::getLinksAndRulers($this->book_id, $links, $rulers); + $this->getLinksAndRulers($links, $rulers); foreach ($links as $link) { if ($link['type'] == '12' && isset($this->config->basketReferences[$link['to']])) { $this->config->basketReferences[$link['to']]['zoom_image'] = 'data/links/zoom_' . $link['uid'] . '.jpg'; @@ -2160,7 +2164,7 @@ height="0" width="0" style="display:none;visibility:hidden"> $this->vdir->copyDirectory($d['dir'], $d['fdir']); } - Links::getLinksAndRulers($this->book_id, $links, $rulers); + $this->getLinksAndRulers($links, $rulers); $this->_fluidbook->normalizeLinks($links); if ($this->fluidbookSettings->basketManager === 'Puma') { @@ -2514,11 +2518,11 @@ height="0" width="0" style="display:none;visibility:hidden"> { Log::error($e); - $c = explode('\\', get_class($link)); + /*$c = explode('\\', get_class($link)); $type = array_pop($c); $type = str_replace('Link', '', $type); - throw new \Exception('Error on the ' . $type . ' link to ' . $link->to . ' on page ' . $link->page . ' with message : ' . $e->getMessage()); + throw new \Exception('Error on the ' . $type . ' link to ' . $link->to . ' on page ' . $link->page . ' with message : ' . $e->getMessage());*/ } protected function _htmlLinkList($list) diff --git a/app/Jobs/FluidbookPackage.php b/app/Jobs/FluidbookPackage.php index b2bb5a084..e1e620d1f 100644 --- a/app/Jobs/FluidbookPackage.php +++ b/app/Jobs/FluidbookPackage.php @@ -3,6 +3,7 @@ namespace App\Jobs; use App\Fluidbook\Packager\Packager; +use Cubist\Util\CommandLine\Rsync; use Illuminate\Support\Facades\Log; class FluidbookPackage extends Base @@ -20,7 +21,9 @@ class FluidbookPackage extends Base { try { $packager = Packager::package($this->getBookId(), $this->getVersion(), false, true, $this->getOptions()); - $this->setResult($packager->getFinalPath()); + $packager->handle(); + (new Rsync($packager->getFinalPath(),$this->getDestination()))->execute(); + $this->setResult(true); } catch (\Exception $e) { $this->setException($e); } diff --git a/composer.lock b/composer.lock index 56983e439..53d4d0f31 100644 --- a/composer.lock +++ b/composer.lock @@ -727,26 +727,25 @@ }, { "name": "brick/math", - "version": "0.10.2", + "version": "0.11.0", "source": { "type": "git", "url": "https://github.com/brick/math.git", - "reference": "459f2781e1a08d52ee56b0b1444086e038561e3f" + "reference": "0ad82ce168c82ba30d1c01ec86116ab52f589478" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/brick/math/zipball/459f2781e1a08d52ee56b0b1444086e038561e3f", - "reference": "459f2781e1a08d52ee56b0b1444086e038561e3f", + "url": "https://api.github.com/repos/brick/math/zipball/0ad82ce168c82ba30d1c01ec86116ab52f589478", + "reference": "0ad82ce168c82ba30d1c01ec86116ab52f589478", "shasum": "" }, "require": { - "ext-json": "*", - "php": "^7.4 || ^8.0" + "php": "^8.0" }, "require-dev": { "php-coveralls/php-coveralls": "^2.2", "phpunit/phpunit": "^9.0", - "vimeo/psalm": "4.25.0" + "vimeo/psalm": "5.0.0" }, "type": "library", "autoload": { @@ -771,7 +770,7 @@ ], "support": { "issues": "https://github.com/brick/math/issues", - "source": "https://github.com/brick/math/tree/0.10.2" + "source": "https://github.com/brick/math/tree/0.11.0" }, "funding": [ { @@ -779,7 +778,7 @@ "type": "github" } ], - "time": "2022-08-10T22:54:19+00:00" + "time": "2023-01-15T23:15:59+00:00" }, { "name": "cache/adapter-common", @@ -1660,13 +1659,13 @@ "source": { "type": "git", "url": "git://git.cubedesigners.com/cubist_cms-back.git", - "reference": "d3c2c4e5e13dfb63d851324d4e87a367219692dc" + "reference": "cd4d4fcc83a76f6c3b15b8f959ed8a9f4d6c0d7b" }, "dist": { "type": "tar", - "url": "https://composer.cubedesigners.com/dist/cubist/cms-back/cubist-cms-back-dev-master-ca37b0.tar", - "reference": "d3c2c4e5e13dfb63d851324d4e87a367219692dc", - "shasum": "1f3141c258a8d6d1a5eaf5c249597ab0053ccae3" + "url": "https://composer.cubedesigners.com/dist/cubist/cms-back/cubist-cms-back-dev-master-cc5f17.tar", + "reference": "cd4d4fcc83a76f6c3b15b8f959ed8a9f4d6c0d7b", + "shasum": "5cf65154b2b704fc6eb57bb4abc1bda4c9047b73" }, "require": { "backpack/backupmanager": "^3.0", @@ -1747,7 +1746,7 @@ } ], "description": "Cubist Backpack extension", - "time": "2023-03-30T14:44:48+00:00" + "time": "2023-03-31T11:53:56+00:00" }, { "name": "cubist/cms-front", @@ -2045,13 +2044,13 @@ "source": { "type": "git", "url": "git://git.cubedesigners.com/cubist_net.git", - "reference": "48d99d29868cf879ddd258e89ff23f1c19820d8e" + "reference": "4dad0f1bddd1e5c0655db0d7a975a1de52c23f22" }, "dist": { "type": "tar", - "url": "https://composer.cubedesigners.com/dist/cubist/net/cubist-net-dev-master-6b4fb6.tar", - "reference": "48d99d29868cf879ddd258e89ff23f1c19820d8e", - "shasum": "47fdf6d79be5d8fbdd6113a1b3d8e67f94436fa4" + "url": "https://composer.cubedesigners.com/dist/cubist/net/cubist-net-dev-master-f3e6ce.tar", + "reference": "4dad0f1bddd1e5c0655db0d7a975a1de52c23f22", + "shasum": "a6e68a4029c88dbded4d4c4eb1a660a1f310a289" }, "require": { "cubist/util": "dev-master", @@ -2075,7 +2074,7 @@ } ], "description": "net cubist composer package", - "time": "2023-02-13T18:16:16+00:00" + "time": "2023-03-31T11:53:22+00:00" }, { "name": "cubist/pdf", @@ -8411,20 +8410,20 @@ }, { "name": "ramsey/uuid", - "version": "4.7.3", + "version": "4.x-dev", "source": { "type": "git", "url": "https://github.com/ramsey/uuid.git", - "reference": "433b2014e3979047db08a17a205f410ba3869cf2" + "reference": "8e955307d32dc9b6992440ff81321d3cb09db75a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/ramsey/uuid/zipball/433b2014e3979047db08a17a205f410ba3869cf2", - "reference": "433b2014e3979047db08a17a205f410ba3869cf2", + "url": "https://api.github.com/repos/ramsey/uuid/zipball/8e955307d32dc9b6992440ff81321d3cb09db75a", + "reference": "8e955307d32dc9b6992440ff81321d3cb09db75a", "shasum": "" }, "require": { - "brick/math": "^0.8.8 || ^0.9 || ^0.10", + "brick/math": "^0.8.8 || ^0.9 || ^0.10 || ^0.11", "ext-json": "*", "php": "^8.0", "ramsey/collection": "^1.2 || ^2.0" @@ -8461,6 +8460,7 @@ "paragonie/random-lib": "Provides RandomLib for use with the RandomLibAdapter", "ramsey/uuid-doctrine": "Allows the use of Ramsey\\Uuid\\Uuid as Doctrine field type." }, + "default-branch": true, "type": "library", "extra": { "captainhook": { @@ -8487,7 +8487,7 @@ ], "support": { "issues": "https://github.com/ramsey/uuid/issues", - "source": "https://github.com/ramsey/uuid/tree/4.7.3" + "source": "https://github.com/ramsey/uuid/tree/4.x" }, "funding": [ { @@ -8499,7 +8499,7 @@ "type": "tidelift" } ], - "time": "2023-01-12T18:13:24+00:00" + "time": "2023-03-27T22:05:11+00:00" }, { "name": "react/promise", @@ -15880,5 +15880,5 @@ "ext-zlib": "*" }, "platform-dev": [], - "plugin-api-version": "2.3.0" + "plugin-api-version": "2.1.0" }