From e7970bdbb3aa038f9c921eff77b5212912392e06 Mon Sep 17 00:00:00 2001 From: zaxar163 Date: Thu, 24 Jan 2019 15:43:39 +0300 Subject: [PATCH] =?UTF-8?q?[FIX]=20=D0=A4=D0=B8=D0=BA=D1=81=20=D0=BF=D1=80?= =?UTF-8?q?=D0=BE=D0=B2=D0=B5=D1=80=D0=BA=D0=B8=20=D0=B2=D0=B5=D1=80=D1=81?= =?UTF-8?q?=D0=B8=D0=B8.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/ru/gravit/launchserver/Updater.java | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/Updater.java b/LaunchServer/src/main/java/ru/gravit/launchserver/Updater.java index 2fb267be..7136de39 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/Updater.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/Updater.java @@ -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)));