mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-12-23 00:51:01 +03:00
[FEATURE] Updates and profiles sync in new thread
This commit is contained in:
parent
63891cd743
commit
fc13442c89
3 changed files with 41 additions and 11 deletions
|
@ -15,10 +15,7 @@
|
||||||
import pro.gravit.launchserver.launchermodules.LauncherModuleLoader;
|
import pro.gravit.launchserver.launchermodules.LauncherModuleLoader;
|
||||||
import pro.gravit.launchserver.manangers.*;
|
import pro.gravit.launchserver.manangers.*;
|
||||||
import pro.gravit.launchserver.manangers.hook.AuthHookManager;
|
import pro.gravit.launchserver.manangers.hook.AuthHookManager;
|
||||||
import pro.gravit.launchserver.modules.events.LaunchServerFullInitEvent;
|
import pro.gravit.launchserver.modules.events.*;
|
||||||
import pro.gravit.launchserver.modules.events.LaunchServerInitPhase;
|
|
||||||
import pro.gravit.launchserver.modules.events.LaunchServerPostInitPhase;
|
|
||||||
import pro.gravit.launchserver.modules.events.NewLaunchServerInstanceEvent;
|
|
||||||
import pro.gravit.launchserver.modules.impl.LaunchServerModulesManager;
|
import pro.gravit.launchserver.modules.impl.LaunchServerModulesManager;
|
||||||
import pro.gravit.launchserver.socket.handlers.NettyServerSocketHandler;
|
import pro.gravit.launchserver.socket.handlers.NettyServerSocketHandler;
|
||||||
import pro.gravit.utils.command.Command;
|
import pro.gravit.utils.command.Command;
|
||||||
|
@ -163,14 +160,23 @@ public LaunchServer(LaunchServerDirectories directories, LaunchServerEnv env, La
|
||||||
LogHelper.debug("Init components successful");
|
LogHelper.debug("Init components successful");
|
||||||
}
|
}
|
||||||
// Sync updates dir
|
// Sync updates dir
|
||||||
if (!IOHelper.isDir(updatesDir))
|
CommonHelper.newThread("Profiles and updates sync", true, () -> {
|
||||||
Files.createDirectory(updatesDir);
|
try {
|
||||||
syncUpdatesDir(null);
|
if (!IOHelper.isDir(updatesDir))
|
||||||
|
Files.createDirectory(updatesDir);
|
||||||
|
syncUpdatesDir(null);
|
||||||
|
modulesManager.invokeEvent(new LaunchServerUpdatesSyncEvent(this));
|
||||||
|
|
||||||
// Sync profiles dir
|
// Sync profiles dir
|
||||||
if (!IOHelper.isDir(profilesDir))
|
if (!IOHelper.isDir(profilesDir))
|
||||||
Files.createDirectory(profilesDir);
|
Files.createDirectory(profilesDir);
|
||||||
syncProfilesDir();
|
syncProfilesDir();
|
||||||
|
modulesManager.invokeEvent(new LaunchServerProfilesSyncEvent(this));
|
||||||
|
} catch (IOException e) {
|
||||||
|
LogHelper.error(e);
|
||||||
|
LogHelper.error("Updates/Profiles not synced");
|
||||||
|
}
|
||||||
|
});
|
||||||
launcherModuleLoader.init();
|
launcherModuleLoader.init();
|
||||||
nettyServerSocketHandler = new NettyServerSocketHandler(this);
|
nettyServerSocketHandler = new NettyServerSocketHandler(this);
|
||||||
// post init modules
|
// post init modules
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
package pro.gravit.launchserver.modules.events;
|
||||||
|
|
||||||
|
import pro.gravit.launcher.modules.LauncherModule;
|
||||||
|
import pro.gravit.launchserver.LaunchServer;
|
||||||
|
|
||||||
|
public class LaunchServerProfilesSyncEvent extends LauncherModule.Event {
|
||||||
|
public final LaunchServer server;
|
||||||
|
|
||||||
|
public LaunchServerProfilesSyncEvent(LaunchServer server) {
|
||||||
|
this.server = server;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,12 @@
|
||||||
|
package pro.gravit.launchserver.modules.events;
|
||||||
|
|
||||||
|
import pro.gravit.launcher.modules.LauncherModule;
|
||||||
|
import pro.gravit.launchserver.LaunchServer;
|
||||||
|
|
||||||
|
public class LaunchServerUpdatesSyncEvent extends LauncherModule.Event {
|
||||||
|
public final LaunchServer server;
|
||||||
|
|
||||||
|
public LaunchServerUpdatesSyncEvent(LaunchServer server) {
|
||||||
|
this.server = server;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue