[FIX] Bug fixes

This commit is contained in:
Gravita 2022-08-30 14:26:08 +07:00
parent 7414132bad
commit 2324af1c46
4 changed files with 14 additions and 9 deletions

View file

@ -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<AsyncDownloader.SizedFile> toDownload = new ArrayList<>(128);
for(var e : objects.entrySet()) {
var value = e.getValue().getAsJsonObject();

View file

@ -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());

View file

@ -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);

View file

@ -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)) {