Skip to content

Commit

Permalink
fix: prevent error when run at integration tests
Browse files Browse the repository at this point in the history
Signed-off-by: Vitor Mattos <[email protected]>
  • Loading branch information
vitormattos authored and backportbot-libresign[bot] committed Jan 29, 2025
1 parent 1a98ad6 commit c01223c
Showing 1 changed file with 33 additions and 3 deletions.
36 changes: 33 additions & 3 deletions lib/Service/Install/InstallService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit c01223c

Please sign in to comment.