mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-17 03:08:58 +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(){
|
public function getChannel(){
|
||||||
$channel = strtolower($this->server->getProperty("auto-updater.preferred-channel", "stable"));
|
$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";
|
$channel = "stable";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,17 +51,20 @@ class UpdateCheckTask extends AsyncTask{
|
|||||||
if($response !== false){
|
if($response !== false){
|
||||||
$response = json_decode($response, true);
|
$response = json_decode($response, true);
|
||||||
if(is_array($response)){
|
if(is_array($response)){
|
||||||
$this->setResult(
|
if(
|
||||||
[
|
isset($response["version"]) and
|
||||||
"version" => $response["version"],
|
isset($response["api_version"]) and
|
||||||
"api_version" => $response["api_version"],
|
isset($response["build"]) and
|
||||||
"build" => $response["build"],
|
isset($response["date"]) and
|
||||||
"date" => $response["date"],
|
isset($response["download_url"])
|
||||||
"details_url" => $response["details_url"] ?? null,
|
){
|
||||||
"download_url" => $response["download_url"]
|
$response["details_url"] = $response["details_url"] ?? null;
|
||||||
],
|
$this->setResult($response, true);
|
||||||
true
|
}elseif(isset($response["error"])){
|
||||||
);
|
$this->error = $response["error"];
|
||||||
|
}else{
|
||||||
|
$this->error = "Invalid response data";
|
||||||
|
}
|
||||||
}else{
|
}else{
|
||||||
$this->error = "Invalid response data";
|
$this->error = "Invalid response data";
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user