From 351e3912214af911cb81718c27783de080db94dd Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 30 Jun 2024 22:35:22 +0800 Subject: [PATCH] `--ignore-cache-sources` now support empty values (force all download) --- src/SPC/command/DownloadCommand.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/SPC/command/DownloadCommand.php b/src/SPC/command/DownloadCommand.php index 5ce1a06a..48fa5e7a 100644 --- a/src/SPC/command/DownloadCommand.php +++ b/src/SPC/command/DownloadCommand.php @@ -38,7 +38,7 @@ class DownloadCommand extends BaseCommand $this->addOption('for-extensions', 'e', InputOption::VALUE_REQUIRED, 'Fetch by extensions, e.g "openssl,mbstring"'); $this->addOption('for-libs', 'l', InputOption::VALUE_REQUIRED, 'Fetch by libraries, e.g "libcares,openssl,onig"'); $this->addOption('without-suggestions', null, null, 'Do not fetch suggested sources when using --for-extensions'); - $this->addOption('ignore-cache-sources', null, InputOption::VALUE_REQUIRED, 'Ignore some source caches, comma separated, e.g "php-src,curl,openssl"', ''); + $this->addOption('ignore-cache-sources', null, InputOption::VALUE_OPTIONAL, 'Ignore some source caches, comma separated, e.g "php-src,curl,openssl"', ''); $this->addOption('retry', 'R', InputOption::VALUE_REQUIRED, 'Set retry time when downloading failed (default: 0)', '0'); } @@ -147,8 +147,12 @@ class DownloadCommand extends BaseCommand } $chosen_sources = array_map('trim', array_filter(explode(',', $this->getArgument('sources')))); - $force_list = array_map('trim', array_filter(explode(',', $this->getOption('ignore-cache-sources')))); - + $force_all = empty($this->getOption('ignore-cache-sources')); + if (!$force_all) { + $force_list = array_map('trim', array_filter(explode(',', $this->getOption('ignore-cache-sources')))); + } else { + $force_list = []; + } if ($this->getOption('all')) { logger()->notice('Downloading with --all option will take more times to download, we recommend you to download with --for-extensions option !'); } @@ -182,7 +186,7 @@ class DownloadCommand extends BaseCommand Downloader::downloadSource($source, $new_config, true); } else { logger()->info("Fetching source {$source} [{$ni}/{$cnt}]"); - Downloader::downloadSource($source, Config::getSource($source), in_array($source, $force_list)); + Downloader::downloadSource($source, Config::getSource($source), $force_all || in_array($source, $force_list)); } } $time = round(microtime(true) - START_TIME, 3);