[FEATURE] DirWatcher для params.javaHDir

This commit is contained in:
Gravit 2020-08-02 05:16:18 +07:00
parent c969b16391
commit 1fbad1cfa0
No known key found for this signature in database
GPG key ID: 98A079490768CCE5
2 changed files with 18 additions and 3 deletions

View file

@ -50,7 +50,9 @@ private static ClientLauncherProcess.ClientParams readParams(SocketAddress addre
ClientLauncherProcess.ClientParams params = Launcher.gsonManager.gson.fromJson(new String(serialized, IOHelper.UNICODE_CHARSET), ClientLauncherProcess.ClientParams.class); ClientLauncherProcess.ClientParams params = Launcher.gsonManager.gson.fromJson(new String(serialized, IOHelper.UNICODE_CHARSET), ClientLauncherProcess.ClientParams.class);
params.clientHDir = new HashedDir(input); params.clientHDir = new HashedDir(input);
params.assetHDir = new HashedDir(input); params.assetHDir = new HashedDir(input);
params.javaHDir = new HashedDir(input); boolean isNeedReadJavaDir = input.readBoolean();
if(isNeedReadJavaDir)
params.javaHDir = new HashedDir(input);
return params; return params;
} }
} }
@ -133,8 +135,10 @@ public static void main(String[] args) throws Throwable {
LogHelper.debug("Starting JVM and client WatchService"); LogHelper.debug("Starting JVM and client WatchService");
FileNameMatcher assetMatcher = profile.getAssetUpdateMatcher(); FileNameMatcher assetMatcher = profile.getAssetUpdateMatcher();
FileNameMatcher clientMatcher = profile.getClientUpdateMatcher(); FileNameMatcher clientMatcher = profile.getClientUpdateMatcher();
Path javaDir = Paths.get(System.getProperty("java.home"));
try (DirWatcher assetWatcher = new DirWatcher(assetDir, params.assetHDir, assetMatcher, digest); try (DirWatcher assetWatcher = new DirWatcher(assetDir, params.assetHDir, assetMatcher, digest);
DirWatcher clientWatcher = new DirWatcher(clientDir, params.clientHDir, clientMatcher, digest)) { DirWatcher clientWatcher = new DirWatcher(clientDir, params.clientHDir, clientMatcher, digest);
DirWatcher javaWatcher = params.javaHDir == null ? null : new DirWatcher(javaDir, params.javaHDir, null, digest)) {
// Verify current state of all dirs // Verify current state of all dirs
//verifyHDir(IOHelper.JVM_DIR, jvmHDir.object, null, digest); //verifyHDir(IOHelper.JVM_DIR, jvmHDir.object, null, digest);
//for (OptionalFile s : Launcher.profile.getOptional()) { //for (OptionalFile s : Launcher.profile.getOptional()) {
@ -145,8 +149,13 @@ public static void main(String[] args) throws Throwable {
// Start WatchService, and only then client // Start WatchService, and only then client
CommonHelper.newThread("Asset Directory Watcher", true, assetWatcher).start(); CommonHelper.newThread("Asset Directory Watcher", true, assetWatcher).start();
CommonHelper.newThread("Client Directory Watcher", true, clientWatcher).start(); CommonHelper.newThread("Client Directory Watcher", true, clientWatcher).start();
if(javaWatcher != null)
CommonHelper.newThread("Java Directory Watcher", true, clientWatcher).start();
verifyHDir(assetDir, params.assetHDir, assetMatcher, digest); verifyHDir(assetDir, params.assetHDir, assetMatcher, digest);
verifyHDir(clientDir, params.clientHDir, clientMatcher, digest); verifyHDir(clientDir, params.clientHDir, clientMatcher, digest);
if(javaWatcher != null)
verifyHDir(javaDir, params.javaHDir, null, digest);
if(params.javaHDir != null)
LauncherEngine.modulesManager.invokeEvent(new ClientProcessLaunchEvent(engine, params)); LauncherEngine.modulesManager.invokeEvent(new ClientProcessLaunchEvent(engine, params));
launch(profile, params); launch(profile, params);
} }

View file

@ -150,7 +150,13 @@ public void runWriteParams(SocketAddress address) throws IOException {
output.writeByteArray(serializedMainParams, 0); output.writeByteArray(serializedMainParams, 0);
params.clientHDir.write(output); params.clientHDir.write(output);
params.assetHDir.write(output); params.assetHDir.write(output);
params.javaHDir.write(output); if(params.javaHDir == null || params.javaHDir == params.assetHDir) { //TODO: OLD RUNTIME USE params.assetHDir AS NULL IN java.javaHDir
output.writeBoolean(false);
}
else {
output.writeBoolean(true);
params.javaHDir.write(output);
}
} }
} }
LauncherEngine.modulesManager.invokeEvent(new ClientProcessBuilderParamsWrittedEvent(this)); LauncherEngine.modulesManager.invokeEvent(new ClientProcessBuilderParamsWrittedEvent(this));