mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-11-15 03:31:15 +03:00
Фикс распаковки рантайма
This commit is contained in:
parent
d2858f7c37
commit
5af607327b
2 changed files with 16 additions and 15 deletions
|
@ -33,8 +33,6 @@
|
|||
|
||||
public class MainBuildTask implements LauncherBuildTask {
|
||||
public static LaunchServer server = LaunchServer.server;
|
||||
public final Path runtimeDir;
|
||||
public final Path guardDir;
|
||||
public final Path binaryFile;
|
||||
public Path cleanJar;
|
||||
private final class RuntimeDirVisitor extends SimpleFileVisitor<Path> {
|
||||
|
@ -48,14 +46,14 @@ private RuntimeDirVisitor(ZipOutputStream output, Map<String, byte[]> runtime) {
|
|||
|
||||
@Override
|
||||
public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException {
|
||||
String dirName = IOHelper.toString(runtimeDir.relativize(dir));
|
||||
String dirName = IOHelper.toString(UnpackBuildTask.runtimeDir.relativize(dir));
|
||||
output.putNextEntry(newEntry(dirName + '/'));
|
||||
return super.preVisitDirectory(dir, attrs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
|
||||
String fileName = IOHelper.toString(runtimeDir.relativize(file));
|
||||
String fileName = IOHelper.toString(UnpackBuildTask.runtimeDir.relativize(file));
|
||||
runtime.put(fileName, SecurityHelper.digest(SecurityHelper.DigestAlgorithm.MD5, file));
|
||||
|
||||
// Create zip entry and transfer contents
|
||||
|
@ -80,14 +78,14 @@ private GuardDirVisitor(ZipOutputStream output, Map<String, byte[]> guard) {
|
|||
|
||||
@Override
|
||||
public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException {
|
||||
String dirName = IOHelper.toString(guardDir.relativize(dir));
|
||||
String dirName = IOHelper.toString(UnpackBuildTask.guardDir.relativize(dir));
|
||||
output.putNextEntry(newGuardEntry(dirName + '/'));
|
||||
return super.preVisitDirectory(dir, attrs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
|
||||
String fileName = IOHelper.toString(guardDir.relativize(file));
|
||||
String fileName = IOHelper.toString(UnpackBuildTask.guardDir.relativize(file));
|
||||
guard.put(fileName, SecurityHelper.digest(SecurityHelper.DigestAlgorithm.MD5, file));
|
||||
|
||||
// Create zip entry and transfer contents
|
||||
|
@ -107,8 +105,6 @@ private static ZipEntry newGuardEntry(String fileName) {
|
|||
return newZipEntry(Launcher.GUARD_DIR + IOHelper.CROSS_SEPARATOR + fileName);
|
||||
}
|
||||
public MainBuildTask() {
|
||||
runtimeDir = server.dir.resolve(Launcher.RUNTIME_DIR);
|
||||
guardDir = server.dir.resolve(Launcher.GUARD_DIR);
|
||||
binaryFile = server.dir.resolve(server.config.binaryName + "-main.jar");
|
||||
}
|
||||
|
||||
|
@ -176,7 +172,7 @@ public Path process(Path cleanJar) throws IOException {
|
|||
Map<String, byte[]> runtime = new HashMap<>(256);
|
||||
if (server.buildHookManager.buildRuntime()) {
|
||||
// Write launcher guard dir
|
||||
IOHelper.walk(runtimeDir, new RuntimeDirVisitor(output, runtime), false);
|
||||
IOHelper.walk(UnpackBuildTask.runtimeDir, new RuntimeDirVisitor(output, runtime), false);
|
||||
// IOHelper.walk(guardDir, new GuardDirVisitor(output, runtime), false);
|
||||
}
|
||||
// Create launcher config file
|
||||
|
@ -207,10 +203,4 @@ public Path process(Path cleanJar) throws IOException {
|
|||
public boolean allowDelete() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void tryUnpack() throws IOException {
|
||||
LogHelper.info("Unpacking launcher native guard files and runtime");
|
||||
UnpackHelper.unpackZipNoCheck("guard.zip", guardDir);
|
||||
UnpackHelper.unpackZipNoCheck("runtime.zip", runtimeDir);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
package ru.gravit.launchserver.binary.tasks;
|
||||
|
||||
import ru.gravit.launcher.Launcher;
|
||||
import ru.gravit.launchserver.LaunchServer;
|
||||
import ru.gravit.utils.helper.IOHelper;
|
||||
import ru.gravit.utils.helper.LogHelper;
|
||||
import ru.gravit.utils.helper.UnpackHelper;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -9,7 +11,10 @@
|
|||
import java.nio.file.Path;
|
||||
|
||||
public class UnpackBuildTask implements LauncherBuildTask {
|
||||
public static final Path runtimeDir = LaunchServer.server.dir.resolve(Launcher.RUNTIME_DIR);
|
||||
public static final Path guardDir = LaunchServer.server.dir.resolve(Launcher.GUARD_DIR);
|
||||
public static LaunchServer server = LaunchServer.server;
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "UnpackFromResources";
|
||||
|
@ -27,4 +32,10 @@ public Path process(Path inputFile) throws IOException {
|
|||
public boolean allowDelete() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void tryUnpack() throws IOException {
|
||||
LogHelper.info("Unpacking launcher native guard files and runtime");
|
||||
UnpackHelper.unpackZipNoCheck("guard.zip", guardDir);
|
||||
UnpackHelper.unpackZipNoCheck("runtime.zip", runtimeDir);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue