From 2324af1c46232c96547ec049cb43de1f2f80492d Mon Sep 17 00:00:00 2001 From: Gravita Date: Tue, 30 Aug 2022 14:26:08 +0700 Subject: [PATCH] [FIX] Bug fixes --- .../command/hash/DownloadAssetCommand.java | 6 ++++++ .../launchserver/components/ProGuardComponent.java | 5 ++--- .../launcher/client/ClientLauncherEntryPoint.java | 10 +++++----- .../request/websockets/WebSocketClientHandler.java | 2 +- 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/command/hash/DownloadAssetCommand.java b/LaunchServer/src/main/java/pro/gravit/launchserver/command/hash/DownloadAssetCommand.java index 0c6e8822..596186d0 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/command/hash/DownloadAssetCommand.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/command/hash/DownloadAssetCommand.java @@ -16,6 +16,7 @@ import java.io.Writer; import java.nio.file.Files; import java.nio.file.Path; +import java.nio.file.StandardCopyOption; import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -83,6 +84,11 @@ public void invoke(String... args) throws Exception { logger.info("Save {}", indexPath); Launcher.gsonManager.configGson.toJson(assets, writer); } + if(!assetIndex.equals(versionName)) { + Path targetPath = assetDir.resolve("indexes").resolve(versionName+".json"); + logger.info("Copy {} into {}", indexPath, targetPath); + Files.copy(indexPath, targetPath, StandardCopyOption.REPLACE_EXISTING); + } List toDownload = new ArrayList<>(128); for(var e : objects.entrySet()) { var value = e.getValue().getAsJsonObject(); diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/components/ProGuardComponent.java b/LaunchServer/src/main/java/pro/gravit/launchserver/components/ProGuardComponent.java index d01bf131..6ac0f7ec 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/components/ProGuardComponent.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/components/ProGuardComponent.java @@ -134,7 +134,7 @@ public Path process(Path inputFile) throws IOException { if (component.enabled) { Configuration proguard_cfg = new Configuration(); if (!checkJMods(IOHelper.JVM_DIR.resolve("jmods"))) { - logger.error("Java path: {} is not JDK! Please install JDK", IOHelper.JVM_DIR); + throw new RuntimeException(String.format("Java path: %s is not JDK! Please install JDK", IOHelper.JVM_DIR)); } Path jfxPath = tryFindOpenJFXPath(IOHelper.JVM_DIR); if (checkFXJMods(IOHelper.JVM_DIR.resolve("jmods"))) { @@ -143,8 +143,7 @@ public Path process(Path inputFile) throws IOException { } else if (jfxPath != null && checkFXJMods(jfxPath)) { logger.debug("JMods resolved in {}", jfxPath.toString()); } else { - logger.error("JavaFX jmods not found. May be install OpenJFX?"); - jfxPath = null; + throw new RuntimeException("JavaFX jmods not found. May be install OpenJFX?"); } ConfigurationParser parser = new ConfigurationParser(proguardConf.buildConfig(inputFile, outputJar, jfxPath == null ? new Path[0] : new Path[]{jfxPath}), proguardConf.proguard.toFile(), System.getProperties()); diff --git a/Launcher/src/main/java/pro/gravit/launcher/client/ClientLauncherEntryPoint.java b/Launcher/src/main/java/pro/gravit/launcher/client/ClientLauncherEntryPoint.java index 77bc3b98..ad94d22f 100644 --- a/Launcher/src/main/java/pro/gravit/launcher/client/ClientLauncherEntryPoint.java +++ b/Launcher/src/main/java/pro/gravit/launcher/client/ClientLauncherEntryPoint.java @@ -202,10 +202,10 @@ public static void main(String[] args) throws Throwable { CommonHelper.newThread("Client Directory Watcher", true, clientWatcher).start(); if (javaWatcher != null) CommonHelper.newThread("Java Directory Watcher", true, javaWatcher).start(); - verifyHDir(assetDir, params.assetHDir, assetMatcher, false); - verifyHDir(clientDir, params.clientHDir, clientMatcher, false); + verifyHDir(assetDir, params.assetHDir, assetMatcher, false, false); + verifyHDir(clientDir, params.clientHDir, clientMatcher, false, true); if (javaWatcher != null) - verifyHDir(javaDir, params.javaHDir, null, false); + verifyHDir(javaDir, params.javaHDir, null, false, true); LauncherEngine.modulesManager.invokeEvent(new ClientProcessLaunchEvent(engine, params)); launch(profile, params); } @@ -244,14 +244,14 @@ public static void applyClientOfflineProcessors(OfflineRequestService service, C }); } - public static void verifyHDir(Path dir, HashedDir hdir, FileNameMatcher matcher, boolean digest) throws IOException { + public static void verifyHDir(Path dir, HashedDir hdir, FileNameMatcher matcher, boolean digest, boolean checkExtra) throws IOException { //if (matcher != null) // matcher = matcher.verifyOnly(); // Hash directory and compare (ignore update-only matcher entries, it will break offline-mode) HashedDir currentHDir = new HashedDir(dir, matcher, true, digest); HashedDir.Diff diff = hdir.diff(currentHDir, matcher); - if (!diff.isSame()) { + if (!diff.mismatch.isEmpty() || (checkExtra && !diff.extra.isEmpty())) { diff.extra.walk(File.separator, (e, k, v) -> { if (v.getType().equals(HashedEntry.Type.FILE)) { LogHelper.error("Extra file %s", e); diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/request/websockets/WebSocketClientHandler.java b/LauncherAPI/src/main/java/pro/gravit/launcher/request/websockets/WebSocketClientHandler.java index a3982161..58cd35be 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/request/websockets/WebSocketClientHandler.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/request/websockets/WebSocketClientHandler.java @@ -60,10 +60,10 @@ protected void channelRead0(ChannelHandlerContext ctx, Object msg) throws Except final WebSocketFrame frame = (WebSocketFrame) msg; if (frame instanceof TextWebSocketFrame) { final TextWebSocketFrame textFrame = (TextWebSocketFrame) frame; - clientJSONPoint.onMessage(textFrame.text()); if (LogHelper.isDevEnabled()) { LogHelper.dev("Message: %s", textFrame.text()); } + clientJSONPoint.onMessage(textFrame.text()); // uncomment to print request // logger.info(textFrame.text()); } else if ((frame instanceof PingWebSocketFrame)) {