mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-12-23 17:11:39 +03:00
[FIX] Фикс багов Updater 1 часть - фикс копипаста.
This commit is contained in:
parent
9c34019446
commit
012870cf26
2 changed files with 16 additions and 14 deletions
|
@ -23,6 +23,7 @@
|
||||||
public class Updater extends TimerTask {
|
public class Updater extends TimerTask {
|
||||||
private static final DateTimeFormatter DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern("yyyy.MM.dd HH:mm:ss", Locale.US);
|
private static final DateTimeFormatter DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern("yyyy.MM.dd HH:mm:ss", Locale.US);
|
||||||
private static final long period = 1000*3600;
|
private static final long period = 1000*3600;
|
||||||
|
private static final Version VERSION = Launcher.getVersion();
|
||||||
private final Timer taskPool;
|
private final Timer taskPool;
|
||||||
private final GHRepository gravitLauncher;
|
private final GHRepository gravitLauncher;
|
||||||
|
|
||||||
|
@ -46,8 +47,8 @@ public void run() {
|
||||||
try {
|
try {
|
||||||
GHRelease rel = gravitLauncher.getLatestRelease();
|
GHRelease rel = gravitLauncher.getLatestRelease();
|
||||||
Version relV = parseVer(rel.getTagName());
|
Version relV = parseVer(rel.getTagName());
|
||||||
if (Launcher.getVersion().major >= relV.major || Launcher.getVersion().minor >= relV.minor
|
if (VERSION.major >= relV.major || VERSION.minor >= relV.minor
|
||||||
|| Launcher.getVersion().patch >= relV.patch || Launcher.getVersion().build >= relV.build) return;
|
|| VERSION.patch >= relV.patch || VERSION.build >= relV.build) return;
|
||||||
if (relV.release.equals(Type.STABLE) || relV.release.equals(Type.LTS)) {
|
if (relV.release.equals(Type.STABLE) || relV.release.equals(Type.LTS)) {
|
||||||
LogHelper.warning("New %s release: %s", relV.getReleaseStatus(), relV.getVersionString());
|
LogHelper.warning("New %s release: %s", relV.getReleaseStatus(), relV.getVersionString());
|
||||||
LogHelper.warning("You can download it: " + rel.getHtmlUrl().toString());
|
LogHelper.warning("You can download it: " + rel.getHtmlUrl().toString());
|
||||||
|
@ -65,8 +66,7 @@ public void run() {
|
||||||
private static final Pattern startingVerPattern = Pattern.compile("\\d+\\.\\d+\\.\\d+");
|
private static final Pattern startingVerPattern = Pattern.compile("\\d+\\.\\d+\\.\\d+");
|
||||||
private static final Pattern pointPatternStriper = Pattern.compile("\\.");
|
private static final Pattern pointPatternStriper = Pattern.compile("\\.");
|
||||||
|
|
||||||
private static Version parseVer(String tag) {
|
private static Version parseVer(String relS) {
|
||||||
String relS = "4.3.4-stable";
|
|
||||||
Matcher verMatcher = startingVerPattern.matcher(relS);
|
Matcher verMatcher = startingVerPattern.matcher(relS);
|
||||||
if (!verMatcher.find()) return null;
|
if (!verMatcher.find()) return null;
|
||||||
String[] ver = pointPatternStriper.split(relS.substring(verMatcher.start(), verMatcher.end()));
|
String[] ver = pointPatternStriper.split(relS.substring(verMatcher.start(), verMatcher.end()));
|
||||||
|
@ -78,14 +78,17 @@ private static Version parseVer(String tag) {
|
||||||
private static Type findRelType(String substring) {
|
private static Type findRelType(String substring) {
|
||||||
if (substring.length() < 3 || substring.isEmpty()) return Type.UNKNOWN;
|
if (substring.length() < 3 || substring.isEmpty()) return Type.UNKNOWN;
|
||||||
String tS = substring;
|
String tS = substring;
|
||||||
while (tS.startsWith("-")) tS = tS.substring(1);
|
if (tS.startsWith("-")) tS = tS.substring(1);
|
||||||
tS = tS.toLowerCase(Locale.ENGLISH);
|
tS = tS.toUpperCase(Locale.ENGLISH);
|
||||||
if (tS.contains("lts")) return Type.LTS;
|
Type t = Type.UNKNOWN;
|
||||||
if (tS.contains("stable")) return Type.STABLE;
|
try {
|
||||||
if (tS.contains("dev")) return Type.DEV;
|
t = Type.valueOf(tS);
|
||||||
if (tS.contains("alpha")) return Type.ALPHA;
|
} catch (Throwable ign) { // ignore it
|
||||||
if (tS.contains("beta")) return Type.BETA;
|
}
|
||||||
if (tS.contains("exp")) return Type.EXPERIMENTAL;
|
return t;
|
||||||
return Type.UNKNOWN;
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
System.out.println(parseVer("v3.4.5.6-stable").release);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
import java.nio.file.Path;
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
public final class ClientProfile implements Comparable<ClientProfile> {
|
public final class ClientProfile implements Comparable<ClientProfile> {
|
||||||
|
|
Loading…
Reference in a new issue