From bba0d0ad11ecbc9f64c41db69988fb85d39a76fd Mon Sep 17 00:00:00 2001 From: Nivesh Krishna Date: Thu, 21 Jul 2022 18:36:51 +0530 Subject: [PATCH 1/3] skip all files that are not e-*.zip --- src/Helpers/Builds.php | 53 ++++++++++++++++++------------------------ 1 file changed, 23 insertions(+), 30 deletions(-) diff --git a/src/Helpers/Builds.php b/src/Helpers/Builds.php index fc9d7f0..78caa45 100644 --- a/src/Helpers/Builds.php +++ b/src/Helpers/Builds.php @@ -178,42 +178,35 @@ 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-(.*)\.zip$/i", $filename)) { continue; } + $build = null; - $extension = pathinfo($file, PATHINFO_EXTENSION); + // If APC is enabled + if (extension_loaded('apcu') && ini_get('apc.enabled')) { + $build = apcu_fetch($file); - if ($extension == 'zip') { - $build = null; - - // 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 From 5059eca59c36ac933cbc5eb2e244fc05aa37c496 Mon Sep 17 00:00:00 2001 From: Nivesh Krishna Date: Fri, 22 Jul 2022 00:52:35 +0530 Subject: [PATCH 2/3] fix regex --- src/Helpers/Builds.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Helpers/Builds.php b/src/Helpers/Builds.php index 78caa45..32fcf8a 100644 --- a/src/Helpers/Builds.php +++ b/src/Helpers/Builds.php @@ -176,11 +176,9 @@ if (count($files) > 2) { foreach ($files as $file) { - $filename = pathinfo($file, PATHINFO_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-(.*)\.zip$/i", $filename)) { + if (!preg_match("/^e-[0-9][0-9.]*-(.*)\.zip$/i", $file)) { continue; } $build = null; -- GitLab From b1ae2247ab0a5845184e2cc674b6f71b35a839ff Mon Sep 17 00:00:00 2001 From: Nivesh Krishna Date: Fri, 22 Jul 2022 14:12:11 +0530 Subject: [PATCH 3/3] fix regex --- src/Helpers/Builds.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Helpers/Builds.php b/src/Helpers/Builds.php index 32fcf8a..dc0a413 100644 --- a/src/Helpers/Builds.php +++ b/src/Helpers/Builds.php @@ -178,7 +178,7 @@ foreach ($files as $file) { // 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][0-9.]*-(.*)\.zip$/i", $file)) { + if (!preg_match("/^e-[0-9\.]+-(.*)-$device\.zip$/i", $file)) { continue; } $build = null; -- GitLab