diff --git a/src/Helpers/Builds.php b/src/Helpers/Builds.php index fc9d7f0ceeb431ad86a8b4a35f5b522eb4aa1041..dc0a413b7a0c1ed7b6b45d80839e02deb7eb98fa 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'); } } }