From 193c7c0ad4c31d973679ed25a9793c89f6b80066 Mon Sep 17 00:00:00 2001 From: Vitor Mattos Date: Mon, 17 Jun 2024 12:34:16 -0300 Subject: [PATCH] fix: usage of verify method Previous commit made a wrong usage of verify method Signed-off-by: Vitor Mattos --- lib/Service/Install/InstallService.php | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/lib/Service/Install/InstallService.php b/lib/Service/Install/InstallService.php index bc3f3beaf9..f4e9419494 100644 --- a/lib/Service/Install/InstallService.php +++ b/lib/Service/Install/InstallService.php @@ -99,7 +99,7 @@ private function getFolder(string $path = '', ?ISimpleFolder $folder = null, $ne } $path = explode('/', $path); foreach ($path as $snippet) { - $folder = $this->getFolder($snippet, $folder); + $folder = $this->getFolder($snippet, $folder, $needToBeEmpty); } return $folder; } @@ -340,11 +340,7 @@ public function setResource(string $resource): self { } public function isDownloadedFilesOk(): bool { - try { - return count($this->signSetupService->verify($this->architecture, $this->resource)) === 0; - } catch (InvalidSignatureException|SignatureDataNotFoundException|EmptySignatureDataException|NotFoundException $e) { - return false; - } + return count($this->signSetupService->verify($this->architecture, $this->resource)) === 0; } public function installJava(?bool $async = false): void { @@ -353,10 +349,12 @@ public function installJava(?bool $async = false): void { $this->runAsync(); return; } - $folder = $this->getEmptyFolder($this->resource); $extractDir = $this->getFullPath() . '/' . $this->resource; - if (!$this->isDownloadedFilesOk()) { + if ($this->isDownloadedFilesOk()) { + $folder = $this->getFolder($this->resource); + } else { + $folder = $this->getEmptyFolder($this->resource); /** * Steps to update: * Check the compatible version of Java to use JSignPdf @@ -433,10 +431,12 @@ public function installJSignPdf(?bool $async = false): void { $this->runAsync(); return; } - $folder = $this->getEmptyFolder($this->resource); $extractDir = $this->getFullPath() . '/' . $this->resource; - if (!$this->isDownloadedFilesOk()) { + if ($this->isDownloadedFilesOk()) { + $folder = $this->getFolder($this->resource); + } else { + $folder = $this->getEmptyFolder($this->resource); $compressedFileName = 'jsignpdf-' . JSignPdfHandler::VERSION . '.zip'; try { $compressedFile = $folder->getFile($compressedFileName); @@ -534,9 +534,10 @@ public function installCfssl(?bool $async = false): void { } private function installCfsslByArchitecture(string $arcitecture): void { - $folder = $this->getEmptyFolder($this->resource); - if ($this->isDownloadedFilesOk()) { + $folder = $this->getFolder($this->resource); + } else { + $folder = $this->getEmptyFolder($this->resource); $downloads = [ [ 'file' => 'cfssl_' . self::CFSSL_VERSION . '_linux_' . $arcitecture,