From 1cbfb63abd0173b1bd0d2cda53048c9c6c5afbe3 Mon Sep 17 00:00:00 2001 From: Nivesh Krishna Date: Thu, 21 Jul 2022 16:42:07 +0530 Subject: [PATCH 1/2] fix to md5 sum --- src/Helpers/Build.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Helpers/Build.php b/src/Helpers/Build.php index 78663e2..cce36ff 100644 --- a/src/Helpers/Build.php +++ b/src/Helpers/Build.php @@ -209,7 +209,8 @@ $tmp = explode(" ", file_get_contents($path . '.md5sum')); $ret = $tmp[0]; } elseif ($this->commandExists('md5sum')) { - exec('md5sum ' . $path. ' > '.$path.'.md5sum'); + $dir = rtrim($path, $this->filename); + exec("cd $dir && md5sum " . $this->filename. ' > '.$path.'.md5sum'); $tmp = explode(" ", file_get_contents($path . '.md5sum')); $ret = $tmp[0]; } else { -- GitLab From 4e753b85803d175b618ffe965fc4cab51049993e Mon Sep 17 00:00:00 2001 From: Nivesh Krishna Date: Fri, 22 Jul 2022 10:18:25 +0000 Subject: [PATCH 2/2] skip all files that are not e-number-*.zip --- src/Helpers/Builds.php | 55 ++++++++++++++++++------------------------ 1 file changed, 23 insertions(+), 32 deletions(-) diff --git a/src/Helpers/Builds.php b/src/Helpers/Builds.php index fc9d7f0..dc0a413 100644 --- a/src/Helpers/Builds.php +++ b/src/Helpers/Builds.php @@ -176,44 +176,35 @@ if (count($files) > 2) { foreach ($files as $file) { - $filename = pathinfo($file, PATHINFO_FILENAME); - - if (preg_match("/IMG/i", $filename)) { - continue; - } - - if (preg_match("/latest/i", $filename)) { + // Skip all files except for the ones that match the pattern + // filename starting with e- and ending with .zip are considered as valid files + if (!preg_match("/^e-[0-9\.]+-(.*)-$device\.zip$/i", $file)) { continue; } + $build = null; - $extension = pathinfo($file, PATHINFO_EXTENSION); - - if ($extension == 'zip') { - $build = null; - - // If APC is enabled - if (extension_loaded('apcu') && ini_get('apc.enabled')) { - $build = apcu_fetch($file); + // If APC is enabled + if (extension_loaded('apcu') && ini_get('apc.enabled')) { + $build = apcu_fetch($file); - // If not found there, we have to find it with the old fashion method... - if ($build === false) { - $build = new Build($file, $dir, $this->logger); - // ...and then save it for 72h until it expires again - apcu_store($file, $build, 72*60*60); - } - } else { + // If not found there, we have to find it with the old fashion method... + if ($build === false) { $build = new Build($file, $dir, $this->logger); + // ...and then save it for 72h until it expires again + apcu_store($file, $build, 72*60*60); } - - if ($build->includeInResults($this->postData['params'])) { - array_push($this->builds, $build); - } - - $sourceIncremental = isset($this->postData['params']['source_incremental']) ? $this->postData['params']['source_incremental'] : NULL; - if ($build->isValid($this->postData['params']) && $sourceIncremental && strcmp($sourceIncremental, $build->getIncremental()) === 0) { - $this->currentBuild = $build; - $this->logger->info($build->getIncremental().' is the current build'); - } + } else { + $build = new Build($file, $dir, $this->logger); + } + + if ($build->includeInResults($this->postData['params'])) { + array_push($this->builds, $build); + } + + $sourceIncremental = isset($this->postData['params']['source_incremental']) ? $this->postData['params']['source_incremental'] : NULL; + if ($build->isValid($this->postData['params']) && $sourceIncremental && strcmp($sourceIncremental, $build->getIncremental()) === 0) { + $this->currentBuild = $build; + $this->logger->info($build->getIncremental().' is the current build'); } } } -- GitLab