From 80176ff1e1d7a9bba1ba18dc9e4e79bc07f95db9 Mon Sep 17 00:00:00 2001 From: Gravita <12893402+gravit0@users.noreply.github.com> Date: Tue, 27 Feb 2024 15:53:27 +0700 Subject: [PATCH] [FEATURE] sync updatescache command --- .../command/service/ComponentCommand.java | 1 - .../command/sync/SyncCommand.java | 3 ++- .../command/sync/SyncUpdatesCacheCommand.java | 25 +++++++++++++++++++ .../manangers/UpdatesManager.java | 4 +++ 4 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 LaunchServer/src/main/java/pro/gravit/launchserver/command/sync/SyncUpdatesCacheCommand.java diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/command/service/ComponentCommand.java b/LaunchServer/src/main/java/pro/gravit/launchserver/command/service/ComponentCommand.java index 4ff72e01..576a987b 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/command/service/ComponentCommand.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/command/service/ComponentCommand.java @@ -37,7 +37,6 @@ public void printHelp() { logger.info("Print help for component:"); logger.info("component unload [componentName]"); logger.info("component load [componentName] [filename]"); - logger.info("component gc [componentName]"); } @Override diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/command/sync/SyncCommand.java b/LaunchServer/src/main/java/pro/gravit/launchserver/command/sync/SyncCommand.java index f645eaaa..099e6c25 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/command/sync/SyncCommand.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/command/sync/SyncCommand.java @@ -11,11 +11,12 @@ public SyncCommand(LaunchServer server) { this.childCommands.put("updates", new SyncUpdatesCommand(server)); this.childCommands.put("up", new SyncUPCommand(server)); this.childCommands.put("launchermodules", new SyncLauncherModulesCommand(server)); + this.childCommands.put("updatescache", new SyncUpdatesCacheCommand(server)); } @Override public String getArgsDescription() { - return "[updates/profiles/up/binaries/launchermodules] [args...]"; + return "[updates/profiles/up/binaries/launchermodules/updatescache] [args...]"; } @Override diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/command/sync/SyncUpdatesCacheCommand.java b/LaunchServer/src/main/java/pro/gravit/launchserver/command/sync/SyncUpdatesCacheCommand.java new file mode 100644 index 00000000..19c30fac --- /dev/null +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/command/sync/SyncUpdatesCacheCommand.java @@ -0,0 +1,25 @@ +package pro.gravit.launchserver.command.sync; + +import pro.gravit.launchserver.LaunchServer; +import pro.gravit.launchserver.command.Command; + +public class SyncUpdatesCacheCommand extends Command { + public SyncUpdatesCacheCommand(LaunchServer server) { + super(server); + } + + @Override + public String getArgsDescription() { + return null; + } + + @Override + public String getUsageDescription() { + return "sync updates cache"; + } + + @Override + public void invoke(String... args) throws Exception { + server.updatesManager.readUpdatesFromCache(); + } +} diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/manangers/UpdatesManager.java b/LaunchServer/src/main/java/pro/gravit/launchserver/manangers/UpdatesManager.java index 848fa27b..c2642d2e 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/manangers/UpdatesManager.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/manangers/UpdatesManager.java @@ -52,6 +52,10 @@ private void readCache(Path file) throws IOException { this.updatesDirMap = Collections.unmodifiableMap(updatesDirMap); } + public void readUpdatesFromCache() throws IOException { + readCache(cacheFile); + } + public void readUpdatesDir() throws IOException { if (server.config.cacheUpdates) { if (Files.exists(cacheFile)) {