[FEATURE] sync updatescache command

This commit is contained in:
Gravita 2024-02-27 15:53:27 +07:00
parent 11382d3465
commit 80176ff1e1
4 changed files with 31 additions and 2 deletions

View file

@ -37,7 +37,6 @@ public void printHelp() {
logger.info("Print help for component:"); logger.info("Print help for component:");
logger.info("component unload [componentName]"); logger.info("component unload [componentName]");
logger.info("component load [componentName] [filename]"); logger.info("component load [componentName] [filename]");
logger.info("component gc [componentName]");
} }
@Override @Override

View file

@ -11,11 +11,12 @@ public SyncCommand(LaunchServer server) {
this.childCommands.put("updates", new SyncUpdatesCommand(server)); this.childCommands.put("updates", new SyncUpdatesCommand(server));
this.childCommands.put("up", new SyncUPCommand(server)); this.childCommands.put("up", new SyncUPCommand(server));
this.childCommands.put("launchermodules", new SyncLauncherModulesCommand(server)); this.childCommands.put("launchermodules", new SyncLauncherModulesCommand(server));
this.childCommands.put("updatescache", new SyncUpdatesCacheCommand(server));
} }
@Override @Override
public String getArgsDescription() { public String getArgsDescription() {
return "[updates/profiles/up/binaries/launchermodules] [args...]"; return "[updates/profiles/up/binaries/launchermodules/updatescache] [args...]";
} }
@Override @Override

View file

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

View file

@ -52,6 +52,10 @@ private void readCache(Path file) throws IOException {
this.updatesDirMap = Collections.unmodifiableMap(updatesDirMap); this.updatesDirMap = Collections.unmodifiableMap(updatesDirMap);
} }
public void readUpdatesFromCache() throws IOException {
readCache(cacheFile);
}
public void readUpdatesDir() throws IOException { public void readUpdatesDir() throws IOException {
if (server.config.cacheUpdates) { if (server.config.cacheUpdates) {
if (Files.exists(cacheFile)) { if (Files.exists(cacheFile)) {