Improved AutoUpdater error handling and made it more robust

This commit is contained in:
Dylan K. Taylor 2017-06-11 18:41:18 +01:00
parent 4341fb8347
commit 487233a101
2 changed files with 15 additions and 12 deletions

View File

@ -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";
} }

View File

@ -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";
} }