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

[email protected] (Shivam Mathur)
Newsgroups php.webmaster
Message-ID <[email protected]>
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);
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.