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(){
$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";
}

View File

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