mirror of
https://github.com/GravitLauncher/Launcher
synced 2025-01-09 00:59:44 +03:00
[FIX] Фикс проверки версии.
This commit is contained in:
parent
2a59e8fe0b
commit
e7970bdbb3
1 changed files with 10 additions and 6 deletions
|
@ -28,7 +28,7 @@ public class Updater extends TimerTask {
|
|||
private final Timer taskPool;
|
||||
private final GHRepository gravitLauncher;
|
||||
private Version parent = VERSION;
|
||||
|
||||
|
||||
public Updater(LaunchServer srv) {
|
||||
this.taskPool = new Timer("Updater thread", true);
|
||||
|
||||
|
@ -48,9 +48,13 @@ public void run() {
|
|||
try {
|
||||
GHRelease rel = gravitLauncher.getLatestRelease();
|
||||
Version relV = parseVer(rel.getTagName());
|
||||
if (!relV.equals(parent)) parent = relV;
|
||||
if (VERSION.major >= relV.major || VERSION.minor >= relV.minor
|
||||
|| VERSION.patch >= relV.patch || VERSION.build >= relV.build) return;
|
||||
if (relV == null) {
|
||||
LogHelper.debug("Updater: parsing version error.");
|
||||
return;
|
||||
}
|
||||
if (!parent.equals(relV)) parent = relV;
|
||||
if (VERSION.major >= relV.major && VERSION.minor >= relV.minor
|
||||
&& VERSION.patch >= relV.patch && VERSION.build >= relV.build) return;
|
||||
if (relV.release.equals(Type.STABLE) || relV.release.equals(Type.LTS)) {
|
||||
LogHelper.warning("New %s release: %s", relV.getReleaseStatus(), relV.getVersionString());
|
||||
LogHelper.warning("You can download it: " + rel.getHtmlUrl().toString());
|
||||
|
@ -66,12 +70,12 @@ public void run() {
|
|||
}
|
||||
|
||||
private static final Pattern startingVerPattern = Pattern.compile("\\d+\\.\\d+\\.\\d+");
|
||||
private static final Pattern pointPatternStriper = Pattern.compile("\\.");
|
||||
private static final Pattern pointPatternSpltitter = Pattern.compile("\\.");
|
||||
|
||||
private static Version parseVer(String relS) {
|
||||
Matcher verMatcher = startingVerPattern.matcher(relS);
|
||||
if (!verMatcher.find()) return VERSION;
|
||||
String[] ver = pointPatternStriper.split(relS.substring(verMatcher.start(), verMatcher.end()));
|
||||
String[] ver = pointPatternSpltitter.split(relS.substring(verMatcher.start(), verMatcher.end()));
|
||||
if (ver.length < 3) return VERSION;
|
||||
return new Version(Integer.parseInt(ver[0]), Integer.parseInt(ver[1]),
|
||||
Integer.parseInt(ver[2]), ver.length > 3 ? Integer.parseInt(ver[3]) : 0, findRelType(relS.substring(verMatcher.end()+1)));
|
||||
|
|
Loading…
Reference in a new issue