mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-11-15 11:39:11 +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 class MainBuildTask implements LauncherBuildTask {
|
||||||
public static LaunchServer server = LaunchServer.server;
|
public static LaunchServer server = LaunchServer.server;
|
||||||
public final Path runtimeDir;
|
|
||||||
public final Path guardDir;
|
|
||||||
public final Path binaryFile;
|
public final Path binaryFile;
|
||||||
public Path cleanJar;
|
public Path cleanJar;
|
||||||
private final class RuntimeDirVisitor extends SimpleFileVisitor<Path> {
|
private final class RuntimeDirVisitor extends SimpleFileVisitor<Path> {
|
||||||
|
@ -48,14 +46,14 @@ private RuntimeDirVisitor(ZipOutputStream output, Map<String, byte[]> runtime) {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException {
|
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 + '/'));
|
output.putNextEntry(newEntry(dirName + '/'));
|
||||||
return super.preVisitDirectory(dir, attrs);
|
return super.preVisitDirectory(dir, attrs);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
|
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));
|
runtime.put(fileName, SecurityHelper.digest(SecurityHelper.DigestAlgorithm.MD5, file));
|
||||||
|
|
||||||
// Create zip entry and transfer contents
|
// Create zip entry and transfer contents
|
||||||
|
@ -80,14 +78,14 @@ private GuardDirVisitor(ZipOutputStream output, Map<String, byte[]> guard) {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException {
|
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 + '/'));
|
output.putNextEntry(newGuardEntry(dirName + '/'));
|
||||||
return super.preVisitDirectory(dir, attrs);
|
return super.preVisitDirectory(dir, attrs);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
|
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));
|
guard.put(fileName, SecurityHelper.digest(SecurityHelper.DigestAlgorithm.MD5, file));
|
||||||
|
|
||||||
// Create zip entry and transfer contents
|
// 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);
|
return newZipEntry(Launcher.GUARD_DIR + IOHelper.CROSS_SEPARATOR + fileName);
|
||||||
}
|
}
|
||||||
public MainBuildTask() {
|
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");
|
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);
|
Map<String, byte[]> runtime = new HashMap<>(256);
|
||||||
if (server.buildHookManager.buildRuntime()) {
|
if (server.buildHookManager.buildRuntime()) {
|
||||||
// Write launcher guard dir
|
// 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);
|
// IOHelper.walk(guardDir, new GuardDirVisitor(output, runtime), false);
|
||||||
}
|
}
|
||||||
// Create launcher config file
|
// Create launcher config file
|
||||||
|
@ -207,10 +203,4 @@ public Path process(Path cleanJar) throws IOException {
|
||||||
public boolean allowDelete() {
|
public boolean allowDelete() {
|
||||||
return true;
|
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;
|
package ru.gravit.launchserver.binary.tasks;
|
||||||
|
|
||||||
|
import ru.gravit.launcher.Launcher;
|
||||||
import ru.gravit.launchserver.LaunchServer;
|
import ru.gravit.launchserver.LaunchServer;
|
||||||
import ru.gravit.utils.helper.IOHelper;
|
import ru.gravit.utils.helper.IOHelper;
|
||||||
|
import ru.gravit.utils.helper.LogHelper;
|
||||||
import ru.gravit.utils.helper.UnpackHelper;
|
import ru.gravit.utils.helper.UnpackHelper;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -9,7 +11,10 @@
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
|
|
||||||
public class UnpackBuildTask implements LauncherBuildTask {
|
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;
|
public static LaunchServer server = LaunchServer.server;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return "UnpackFromResources";
|
return "UnpackFromResources";
|
||||||
|
@ -27,4 +32,10 @@ public Path process(Path inputFile) throws IOException {
|
||||||
public boolean allowDelete() {
|
public boolean allowDelete() {
|
||||||
return false;
|
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