Fix mirror selection when reset in Dry Run mode

[GitHub #123]
This commit is contained in:
Aoran Zeng 2024-11-22 09:14:55 +08:00
parent 722de55ecb
commit fd762f9d3c
No known key found for this signature in database
GPG Key ID: 8F8BA8488E10ED98
2 changed files with 13 additions and 9 deletions

View File

@ -19,7 +19,7 @@
* | czyt <czyt.go@gmail.com> * | czyt <czyt.go@gmail.com>
* | * |
* Created On : <2023-08-28> * Created On : <2023-08-28>
* Last Modified : <2024-11-21> * Last Modified : <2024-11-22>
* *
* chsrc: Change Source * chsrc: Change Source
* ------------------------------------------------------------*/ * ------------------------------------------------------------*/
@ -660,10 +660,10 @@ main (int argc, char const *argv[])
if (CliOpt_DryRun) if (CliOpt_DryRun)
{ {
char *dry_msg = CliOpt_InEnglish ? "**Enable [Dry Run] mode. " \ char *dry_msg = CliOpt_InEnglish ? "Enable [Dry Run] mode. " \
"Simulate the source changing process (skipping speed measurement). " \ "Simulate the source changing process (skipping speed measurement). " \
"Commands only print but don't run**\n" "Commands only print but don't run\n"
: "**开启Dry Run模式,模拟换源过程(跳过测速),命令仅打印并不运行**\n"; : "开启Dry Run模式,模拟换源过程(跳过测速),命令仅打印并不运行\n";
chsrc_log (bdyellow(dry_msg)); chsrc_log (bdyellow(dry_msg));
} }

View File

@ -672,9 +672,9 @@ measure_speed_for_every_source (Source_t sources[], int size, double speed_recor
int int
select_mirror_autoly (Source_t *sources, size_t size, const char *target_name) select_mirror_autoly (Source_t *sources, size_t size, const char *target_name)
{ {
if (!CliOpt_DryRun)
{ {
char *msg = CliOpt_InEnglish ? "Measuring speed in sequence" : "测速中"; char *msg = CliOpt_InEnglish ? "Measuring speed in sequence" : "测速中";
xy_log_brkt (App_Name, bdpurple (CliOpt_InEnglish ? "MEASURE" : "测速"), msg); xy_log_brkt (App_Name, bdpurple (CliOpt_InEnglish ? "MEASURE" : "测速"), msg);
br(); br();
} }
@ -689,7 +689,11 @@ select_mirror_autoly (Source_t *sources, size_t size, const char *target_name)
if (CliOpt_DryRun) if (CliOpt_DryRun)
{ {
return 1; // Dry Run 时,跳过测速 /* Dry Run 时,跳过测速 */
if (ProgMode_CMD_Reset)
return 0; /* 选择默认源 */
else
return 1; /* 原则第一个源 */
} }
bool only_one = false; bool only_one = false;