Skip to content

Commit

Permalink
Only check master branch for version information
Browse files Browse the repository at this point in the history
Closes qzind#637
  • Loading branch information
tresf committed May 19, 2020
1 parent 7563857 commit 6cdd307
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/qz/common/AboutInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,6 @@ private static String toISO(Date d) {
}

public static Version findLatestVersion() {
Version latestVersion = Constants.VERSION;

try {
URL api = new URL(Constants.VERSION_CHECK_URL);
BufferedReader br = new BufferedReader(new InputStreamReader(api.openStream()));
Expand All @@ -164,16 +162,22 @@ public static Version findLatestVersion() {
rawJson.append(line);
}

JSONArray json = new JSONArray(rawJson.toString());
latestVersion = Version.valueOf(json.getJSONObject(0).getString("name"));

log.trace("Found latest version: {}", latestVersion);
JSONArray versions = new JSONArray(rawJson.toString());
for(int i = 0; i < versions.length(); i++) {
JSONObject versionData = versions.getJSONObject(i);
if(versionData.getString("target_commitish").equals("master")) {
Version latestVersion = Version.valueOf(versionData.getString("name"));
log.trace("Found latest version: {}", latestVersion);
return latestVersion;
}
}
log.error("Failed to get latest version info");
}
catch(Exception e) {
log.error("Failed to get latest version info", e);
}

return latestVersion;
return Constants.VERSION;
}

}

0 comments on commit 6cdd307

Please sign in to comment.