From c01223c948552519f1cfe9b2d444036df76597d2 Mon Sep 17 00:00:00 2001 From: Vitor Mattos Date: Wed, 29 Jan 2025 19:19:54 -0300 Subject: [PATCH] fix: prevent error when run at integration tests Signed-off-by: Vitor Mattos --- lib/Service/Install/InstallService.php | 36 +++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/lib/Service/Install/InstallService.php b/lib/Service/Install/InstallService.php index 9cb9a7daa..2561fad39 100644 --- a/lib/Service/Install/InstallService.php +++ b/lib/Service/Install/InstallService.php @@ -372,7 +372,15 @@ public function installJava(?bool $async = false): void { throw new RuntimeException(sprintf('OS_FAMILY %s is incompatible with LibreSign.', PHP_OS_FAMILY)); } - if (!$this->isDownloadedFilesOk()) { + if ($this->isDownloadedFilesOk()) { + // The binaries files could exists but not saved at database + if (!$this->appConfig->getValueString(Application::APP_ID, 'java_path')) { + $linuxDistribution = $this->getLinuxDistributionToDownloadJava(); + $folder = $this->getFolder('/' . $linuxDistribution . '/' . $this->resource); + $extractDir = $this->getInternalPathOfFolder($folder); + $this->appConfig->setValueString(Application::APP_ID, 'java_path', $extractDir . '/jdk-' . self::JAVA_URL_PATH_NAME . '-jre/bin/java'); + } + } else { /** * Steps to update: * Check the compatible version of Java to use JSignPdf @@ -458,7 +466,15 @@ public function installJSignPdf(?bool $async = false): void { return; } - if (!$this->isDownloadedFilesOk()) { + if ($this->isDownloadedFilesOk()) { + // The binaries files could exists but not saved at database + if (!$this->appConfig->getValueString(Application::APP_ID, 'jsignpdf_jar_path')) { + $folder = $this->getFolder($this->resource); + $extractDir = $this->getInternalPathOfFolder($folder); + $fullPath = $extractDir . '/jsignpdf-' . JSignPdfHandler::VERSION . '/JSignPdf.jar'; + $this->appConfig->setValueString(Application::APP_ID, 'jsignpdf_jar_path', $fullPath); + } + } else { $folder = $this->getFolder($this->resource); $compressedFileName = 'jsignpdf-' . JSignPdfHandler::VERSION . '.zip'; try { @@ -506,7 +522,15 @@ public function installPdftk(?bool $async = false): void { return; } - if (!$this->isDownloadedFilesOk()) { + if ($this->isDownloadedFilesOk()) { + // The binaries files could exists but not saved at database + if (!$this->appConfig->getValueString(Application::APP_ID, 'pdftk_path')) { + $folder = $this->getFolder($this->resource); + $file = $folder->getFile('pdftk.jar'); + $fullPath = $this->getInternalPathOfFile($file); + $this->appConfig->setValueString(Application::APP_ID, 'pdftk_path', $fullPath); + } + } else { $folder = $this->getFolder($this->resource); try { $file = $folder->getFile('pdftk.jar'); @@ -560,6 +584,12 @@ public function installCfssl(?bool $async = false): void { private function installCfsslByArchitecture(string $architecture): void { if ($this->isDownloadedFilesOk()) { + // The binaries files could exists but not saved at database + if (!$this->isCfsslBinInstalled()) { + $folder = $this->getFolder($this->resource); + $cfsslBinPath = $this->getInternalPathOfFolder($folder) . '/cfssl'; + $this->appConfig->setValueString(Application::APP_ID, 'cfssl_bin', $cfsslBinPath); + } return; } $folder = $this->getFolder($this->resource);