mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-16 10:49:10 +00:00
Improved AutoUpdater error handling and made it more robust
This commit is contained in:
parent
4341fb8347
commit
487233a101
@ -164,7 +164,7 @@ class AutoUpdater{
|
||||
*/
|
||||
public function getChannel(){
|
||||
$channel = strtolower($this->server->getProperty("auto-updater.preferred-channel", "stable"));
|
||||
if($channel !== "stable" and $channel !== "beta" and $channel !== "development"){
|
||||
if($channel !== "stable" and $channel !== "beta" and $channel !== "alpha" and $channel !== "development"){
|
||||
$channel = "stable";
|
||||
}
|
||||
|
||||
|
@ -51,17 +51,20 @@ class UpdateCheckTask extends AsyncTask{
|
||||
if($response !== false){
|
||||
$response = json_decode($response, true);
|
||||
if(is_array($response)){
|
||||
$this->setResult(
|
||||
[
|
||||
"version" => $response["version"],
|
||||
"api_version" => $response["api_version"],
|
||||
"build" => $response["build"],
|
||||
"date" => $response["date"],
|
||||
"details_url" => $response["details_url"] ?? null,
|
||||
"download_url" => $response["download_url"]
|
||||
],
|
||||
true
|
||||
);
|
||||
if(
|
||||
isset($response["version"]) and
|
||||
isset($response["api_version"]) and
|
||||
isset($response["build"]) and
|
||||
isset($response["date"]) and
|
||||
isset($response["download_url"])
|
||||
){
|
||||
$response["details_url"] = $response["details_url"] ?? null;
|
||||
$this->setResult($response, true);
|
||||
}elseif(isset($response["error"])){
|
||||
$this->error = $response["error"];
|
||||
}else{
|
||||
$this->error = "Invalid response data";
|
||||
}
|
||||
}else{
|
||||
$this->error = "Invalid response data";
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user