From 30c593c5d59a514cfa8026c016b1f23607f13891 Mon Sep 17 00:00:00 2001 From: HorstOeko Date: Fri, 12 Apr 2024 12:58:48 +0200 Subject: [PATCH] KositValidator -> Cache downloaded versions --- src/ZugferdKositValidator.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/ZugferdKositValidator.php b/src/ZugferdKositValidator.php index 14dc0d99..eda8ec38 100644 --- a/src/ZugferdKositValidator.php +++ b/src/ZugferdKositValidator.php @@ -325,7 +325,9 @@ public function validate(): ZugferdKositValidator */ private function resolveBaseDirectory(): string { - $baseDirectory = PathUtils::combinePathWithPath($this->baseDirectory, "kositvalidator"); + $baseDirectorySuffix = md5($this->validatorDownloadUrl . $this->validatorScenarioDownloadUrl); + + $baseDirectory = PathUtils::combinePathWithPath($this->baseDirectory, sprintf("kositvalidator-%s", $baseDirectorySuffix)); if (!is_dir($baseDirectory)) { @mkdir($baseDirectory); @@ -666,11 +668,7 @@ private function unpackRequiredFile(string $filename): bool */ private function performValidation(): bool { - $jarFilename = $this->resolveAppJarFilename(); - $scenarioFilename = $this->resolveAppScenarioFilename(); - $fileToValidateFilename = $this->resolveFileToValidateFilename(); - - if (file_put_contents($fileToValidateFilename, $this->document->serializeAsXml()) === false) { + if (file_put_contents($this->resolveFileToValidateFilename(), $this->document->serializeAsXml()) === false) { $this->addToMessageBag("Cannot create temporary file which contains the XML to validate"); return false; } @@ -678,12 +676,12 @@ private function performValidation(): bool $applicationOptions = [ 'java', '-jar', - $jarFilename, + $this->resolveAppJarFilename(), '-r', $this->resolveBaseDirectory(), '-s', - $scenarioFilename, - $fileToValidateFilename + $this->resolveAppScenarioFilename(), + $this->resolveFileToValidateFilename() ]; if (!$this->runValidationApplication($applicationOptions, $this->resolveBaseDirectory())) { @@ -805,6 +803,8 @@ private function runValidationApplication(array $command, string $workingdirecto $process->run(); if (!$process->isSuccessful()) { + echo "Dir " . $this->resolveBaseDirectory(); + echo "Exitcode " . $process->getExitCode(); if ($process->getExitCode() == -1) { $this->addToMessageBag("Parsing error. The commandline arguments specified are incorrect", static::MSG_TYPE_VALIDATIONERROR); }