diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/binary/BinaryPipeline.java b/LaunchServer/src/main/java/pro/gravit/launchserver/binary/BinaryPipeline.java index 86fbf9c3..c735d0e0 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/binary/BinaryPipeline.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/binary/BinaryPipeline.java @@ -14,11 +14,11 @@ import java.util.function.Predicate; import java.util.stream.Collectors; -public class BinaryPipeline { +public abstract class BinaryPipeline { public final List tasks = new ArrayList<>(); public final Path buildDir; public final String nameFormat; - private transient final Logger logger = LogManager.getLogger(); + protected transient final Logger logger = LogManager.getLogger(); public BinaryPipeline(Path buildDir, String nameFormat) { this.buildDir = buildDir; @@ -80,27 +80,6 @@ public Optional getTaskBefore(Predicate pr return Optional.empty(); } - public void build(Path target, boolean deleteTempFiles) throws IOException { - logger.info("Building launcher binary file"); - Path thisPath = null; - long time_start = System.currentTimeMillis(); - long time_this = time_start; - for (LauncherBuildTask task : tasks) { - logger.info("Task {}", task.getName()); - Path oldPath = thisPath; - thisPath = task.process(oldPath); - long time_task_end = System.currentTimeMillis(); - long time_task = time_task_end - time_this; - time_this = time_task_end; - logger.info("Task {} processed from {} millis", task.getName(), time_task); - } - long time_end = System.currentTimeMillis(); - if (deleteTempFiles) IOHelper.move(thisPath, target); - else IOHelper.copy(thisPath, target); - IOHelper.deleteDir(buildDir, false); - logger.info("Build successful from {} millis", time_end - time_start); - } - public String nextName(String taskName) { return nameFormat.formatted(taskName); } diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/binary/LauncherBinary.java b/LaunchServer/src/main/java/pro/gravit/launchserver/binary/LauncherBinary.java index a4ba76c0..6a2d4e97 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/binary/LauncherBinary.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/binary/LauncherBinary.java @@ -1,11 +1,13 @@ package pro.gravit.launchserver.binary; import pro.gravit.launchserver.LaunchServer; +import pro.gravit.launchserver.binary.tasks.LauncherBuildTask; import pro.gravit.utils.helper.IOHelper; import pro.gravit.utils.helper.SecurityHelper; import java.io.IOException; import java.nio.file.Path; +import java.util.Map; public abstract class LauncherBinary extends BinaryPipeline { public final LaunchServer server; @@ -19,11 +21,27 @@ protected LauncherBinary(LaunchServer server, Path binaryFile, String nameFormat } public static Path resolve(LaunchServer server, String ext) { - return server.config.copyBinaries ? server.updatesDir.resolve(server.config.binaryName + ext) : server.dir.resolve(server.config.binaryName + ext); + return Path.of(server.config.binaryName + ext); } public void build() throws IOException { - build(syncBinaryFile, server.config.launcher.deleteTempFiles); + logger.info("Building launcher binary file"); + Path thisPath = null; + long time_start = System.currentTimeMillis(); + long time_this = time_start; + for (LauncherBuildTask task : tasks) { + logger.info("Task {}", task.getName()); + Path oldPath = thisPath; + thisPath = task.process(oldPath); + long time_task_end = System.currentTimeMillis(); + long time_task = time_task_end - time_this; + time_this = time_task_end; + logger.info("Task {} processed from {} millis", task.getName(), time_task); + } + long time_end = System.currentTimeMillis(); + server.config.updatesProvider.upload(null, Map.of(syncBinaryFile.toString(), thisPath), true); + IOHelper.deleteDir(buildDir, false); + logger.info("Build successful from {} millis", time_end - time_start); } public final boolean exists() { diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/command/profiles/DeleteProfileCommand.java b/LaunchServer/src/main/java/pro/gravit/launchserver/command/profiles/DeleteProfileCommand.java index 034d791b..f6a36659 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/command/profiles/DeleteProfileCommand.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/command/profiles/DeleteProfileCommand.java @@ -40,14 +40,13 @@ public void invoke(String... args) throws Exception { logger.error("Profile {} not found", args[0]); return; } - var clientDir = server.updatesDir.resolve(profile.getDir()).toAbsolutePath(); - logger.warn("THIS ACTION DELETE PROFILE AND ALL FILES IN {}", clientDir); + logger.warn("THIS ACTION DELETE PROFILE AND ALL FILES IN {}", profile.getDir()); if(!showApplyDialog("Continue?")) { return; } logger.info("Delete {} ({})", profile.getTitle(), profile.getUUID()); server.config.profileProvider.deleteProfile(profile); - logger.info("Delete {}", clientDir); - IOHelper.deleteDir(clientDir, true); + logger.info("Delete {}", profile.getDir()); + server.config.updatesProvider.delete(profile.getDir()); } }