Skip to content
This repository was archived by the owner on Mar 12, 2025. It is now read-only.

Commit ab66ced

Browse files
committed
✨ 支持在下载错误的时候输出错误状态码/优化输出错误逻辑
1 parent 8bd1eed commit ab66ced

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

inc/cluster.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ private function downloader(Swoole\Coroutine\Http\Client $client, $file,$bar) {
135135
mlog("Error connecting to the main control:{$client->errMsg}",2);
136136
return false;
137137
}
138-
elseif($client->statusCode == "200"){
138+
elseif($client->statusCode == 200){
139139
$bar->progress();
140140
return true;
141141
}
@@ -173,7 +173,7 @@ private function downloader(Swoole\Coroutine\Http\Client $client, $file,$bar) {
173173
}
174174
if (!$downloader) {
175175
echo PHP_EOL;
176-
mlog("{$file->path} Download Failed: {$client->errMsg} From Node: {$location_url['host']}:{$location_url['port']}",2);
176+
mlog("{$file->path} Download Failed: {$client->errMsg} | {$location_url['host']}:{$location_url['port']}",2);
177177
$bar->progress();
178178
return false;
179179
}
@@ -186,7 +186,13 @@ private function downloader(Swoole\Coroutine\Http\Client $client, $file,$bar) {
186186
else{
187187
if (!$downloader) {
188188
echo PHP_EOL;
189-
mlog("{$file->path} Download Failed: {$client->errMsg} From Node: {$location_url['host']}:{$location_url['port']}",2);
189+
mlog("{$file->path} Download Failed: {$client->errMsg} | {$location_url['host']}:{$location_url['port']}",2);
190+
$bar->progress();
191+
return false;
192+
}
193+
elseif($client->statusCode >= 400){
194+
echo PHP_EOL;
195+
mlog("Download Failed:{$client->statusCode} | {$file->path} | {$location_url['host']}:{$location_url['port']}",2);
190196
$bar->progress();
191197
return false;
192198
}

main.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
run(function()use ($config){
2323
//注册信号处理器
2424
function registerSigintHandler() {
25-
global $tokentimerid;
25+
global $tokentimerid;
2626
$shouldExit = false; // 初始化为false
2727
Swoole\Process::signal(SIGINT, function ($signo) use ($tokentimerid) {
2828
try {

0 commit comments

Comments
 (0)