Extend UpdateChecker logging

This commit is contained in:
JFronny 2021-10-31 17:44:55 +01:00
parent 38392dc9e2
commit 6e473a19ee
No known key found for this signature in database
GPG Key ID: BEC5ACBBD4EE17E5
4 changed files with 14 additions and 6 deletions

View File

@ -49,7 +49,7 @@ public class UpdateCheckCommand extends Command {
Inceptum.LOGGER.error("No stable version was found, switching to experimental channel");
Inceptum.CONFIG.channel = channel;
Inceptum.saveConfig();
}, Inceptum.LOGGER::error, Inceptum.LOGGER::error);
}, Inceptum.LOGGER::info, Inceptum.LOGGER::error, Inceptum.LOGGER::error);
}
public static void update(UpdateInfo source, boolean relaunch) throws IOException, URISyntaxException {

View File

@ -1,6 +1,7 @@
package io.gitlab.jfronny.inceptum.windows;
import imgui.ImGui;
import io.gitlab.jfronny.inceptum.Inceptum;
public class AboutWindow extends Window {
public AboutWindow() {
@ -9,7 +10,7 @@ public class AboutWindow extends Window {
@Override
public void draw() {
ImGui.text("Inceptum Copyright (C) 2021 JFronny");
ImGui.text("Inceptum " + Inceptum.VERSION.version + " Copyright (C) 2021 JFronny");
ImGui.text("This program comes with ABSOLUTELY NO WARRANTY.");
ImGui.text("This is free software, and you are welcome to redistribute it under certain conditions.");
}

View File

@ -26,7 +26,7 @@ public class Wrapper {
p = p.resolve("run/libraries/io/gitlab/jfronny/inceptum/Inceptum");
if (!Files.exists(p)) {
System.err.println("No Inceptum jar was identified");
UpdateInfo ui = UpdateChecker.check(UpdateChannel.Stable, new ComparableVersion("0"), OSCheck.OS.getMojName(), c -> {}, System.err::println, (s, e) -> {
UpdateInfo ui = UpdateChecker.check(UpdateChannel.Stable, new ComparableVersion("0"), OSCheck.OS.getMojName(), c -> {}, System.out::println, System.err::println, (s, e) -> {
e.printStackTrace();
System.err.println(s);
});

View File

@ -16,9 +16,12 @@ import java.util.function.Consumer;
public class UpdateChecker {
private static final long PROJECT_ID = 30862253L;
public static UpdateInfo check(UpdateChannel channel, ComparableVersion current, String flavor, Consumer<UpdateChannel> channelInvalid, Consumer<String> error, BiConsumer<String, Exception> showError) {
public static UpdateInfo check(UpdateChannel channel, ComparableVersion current, String flavor, Consumer<UpdateChannel> channelInvalid, Consumer<String> out, Consumer<String> error, BiConsumer<String, Exception> showError) {
try {
if (flavor.equals("custom")) return null;
if (flavor.equals("custom")) {
out.accept("Custom build, skipping update check");
return null;
}
GitlabProject project = GitlabApi.getProject(PROJECT_ID);
PackageInfo experimental = null;
PackageInfo stable = null;
@ -45,7 +48,11 @@ public class UpdateChecker {
case CI -> experimental;
case Stable -> stable;
};
if (current.compareTo(new ComparableVersion(info.version)) >= 0) return null;
out.accept("Latest version is " + info.version + ", current is " + current);
if (current.compareTo(new ComparableVersion(info.version)) >= 0) {
out.accept("Up-to-date");
return null;
}
PackageFileInfo file = GitlabApi.getFile(project, info, f -> f.file_name.endsWith('-' + flavor + ".jar"));
if (file == null)
error.accept("No valid package was discovered");