Skip to content

Commit bbf7dd0

Browse files
fix: prevent error when run at integration tests
Signed-off-by: Vitor Mattos <vitor@php.rio>
1 parent 21331f8 commit bbf7dd0

File tree

1 file changed

+33
-3
lines changed

1 file changed

+33
-3
lines changed

lib/Service/Install/InstallService.php

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,15 @@ public function installJava(?bool $async = false): void {
388388
throw new RuntimeException(sprintf('OS_FAMILY %s is incompatible with LibreSign.', PHP_OS_FAMILY));
389389
}
390390

391-
if (!$this->isDownloadedFilesOk()) {
391+
if ($this->isDownloadedFilesOk()) {
392+
// The binaries files could exists but not saved at database
393+
if (!$this->appConfig->getValueString(Application::APP_ID, 'java_path')) {
394+
$linuxDistribution = $this->getLinuxDistributionToDownloadJava();
395+
$folder = $this->getFolder('/' . $linuxDistribution . '/' . $this->resource);
396+
$extractDir = $this->getInternalPathOfFolder($folder);
397+
$this->appConfig->setValueString(Application::APP_ID, 'java_path', $extractDir . '/jdk-' . self::JAVA_URL_PATH_NAME . '-jre/bin/java');
398+
}
399+
} else {
392400
/**
393401
* Steps to update:
394402
* Check the compatible version of Java to use JSignPdf
@@ -474,7 +482,15 @@ public function installJSignPdf(?bool $async = false): void {
474482
return;
475483
}
476484

477-
if (!$this->isDownloadedFilesOk()) {
485+
if ($this->isDownloadedFilesOk()) {
486+
// The binaries files could exists but not saved at database
487+
if (!$this->appConfig->getValueString(Application::APP_ID, 'jsignpdf_jar_path')) {
488+
$folder = $this->getFolder($this->resource);
489+
$extractDir = $this->getInternalPathOfFolder($folder);
490+
$fullPath = $extractDir . '/jsignpdf-' . JSignPdfHandler::VERSION . '/JSignPdf.jar';
491+
$this->appConfig->setValueString(Application::APP_ID, 'jsignpdf_jar_path', $fullPath);
492+
}
493+
} else {
478494
$folder = $this->getFolder($this->resource);
479495
$compressedFileName = 'jsignpdf-' . JSignPdfHandler::VERSION . '.zip';
480496
try {
@@ -522,7 +538,15 @@ public function installPdftk(?bool $async = false): void {
522538
return;
523539
}
524540

525-
if (!$this->isDownloadedFilesOk()) {
541+
if ($this->isDownloadedFilesOk()) {
542+
// The binaries files could exists but not saved at database
543+
if (!$this->appConfig->getValueString(Application::APP_ID, 'pdftk_path')) {
544+
$folder = $this->getFolder($this->resource);
545+
$file = $folder->getFile('pdftk.jar');
546+
$fullPath = $this->getInternalPathOfFile($file);
547+
$this->appConfig->setValueString(Application::APP_ID, 'pdftk_path', $fullPath);
548+
}
549+
} else {
526550
$folder = $this->getFolder($this->resource);
527551
try {
528552
$file = $folder->getFile('pdftk.jar');
@@ -576,6 +600,12 @@ public function installCfssl(?bool $async = false): void {
576600

577601
private function installCfsslByArchitecture(string $architecture): void {
578602
if ($this->isDownloadedFilesOk()) {
603+
// The binaries files could exists but not saved at database
604+
if (!$this->isCfsslBinInstalled()) {
605+
$folder = $this->getFolder($this->resource);
606+
$cfsslBinPath = $this->getInternalPathOfFolder($folder) . '/cfssl';
607+
$this->appConfig->setValueString(Application::APP_ID, 'cfssl_bin', $cfsslBinPath);
608+
}
579609
return;
580610
}
581611
$folder = $this->getFolder($this->resource);

0 commit comments

Comments
 (0)