[web-downloads] main: Refactor updatePackagesFile function to update all libraries

From: Date: Wed, 19 Nov 2025 01:18:28 +0000
Subject: [web-downloads] main: Refactor updatePackagesFile function to update all libraries
Groups: php.webmaster 
Request: Send a blank email to php-webmaster+get-33362@lists.php.net to get a copy of this message
Author: Shivam Mathur (shivammathur) Date: 2025-11-19T06:46:01+05:30 Commit: https://github.com/php/web-downloads/commit/3b88121fc0f20dce6221f9cd52fccb1b4eebc53b Raw diff: https://github.com/php/web-downloads/commit/3b88121fc0f20dce6221f9cd52fccb1b4eebc53b.diff Refactor updatePackagesFile function to update all libraries Changed paths: M src/Console/Command/WinlibsCommand.php Diff: diff --git a/src/Console/Command/WinlibsCommand.php b/src/Console/Command/WinlibsCommand.php index 40888d9..df8fb97 100644 --- a/src/Console/Command/WinlibsCommand.php +++ b/src/Console/Command/WinlibsCommand.php @@ -176,37 +176,14 @@ private function updatePackagesFile(array $files, string $library): void { $baseDirectory = $this->baseDirectory . "/pecl/deps"; $packagesFile = $baseDirectory . "/packages.txt"; - $syncFile = $packagesFile . '.sync'; if (!is_dir($baseDirectory)) { mkdir($baseDirectory, 0755, true); } - $file_lines = []; - if (file_exists($packagesFile)) { - $file_lines = file($packagesFile, FILE_IGNORE_NEW_LINES); - } - - if(!file_exists($syncFile)) { - $file_lines = array_map(function($file) { - return basename($file); - }, glob($baseDirectory . '/*.zip')); - } else { - foreach ($files as $file) { - $fileName = str_replace($file['artifact_name'], $library, $file['file_name']); - $found = false; - foreach ($file_lines as $no => $line) { - if (str_starts_with($line, $library)) { - $file_lines[$no] = $fileName; - $found = true; - } - } - if (!$found) { - $file_lines[] = $fileName; - } - } - } - sort($file_lines); + $file_lines = array_map(function($file) { + return basename($file); + }, glob($baseDirectory . '/*.zip')); file_put_contents($packagesFile, implode("\n", $file_lines)); if(!file_exists($syncFile)) { touch($syncFile);

« previous php.webmaster (#33362) next »