mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-12-23 00:51:01 +03:00
[FIX] UpdateRequest реализован
This commit is contained in:
parent
85eb2d205b
commit
50adbac117
5 changed files with 19 additions and 16 deletions
|
@ -10,7 +10,7 @@
|
||||||
import ru.gravit.launchserver.socket.websocket.json.JsonResponseInterface;
|
import ru.gravit.launchserver.socket.websocket.json.JsonResponseInterface;
|
||||||
|
|
||||||
public class UpdateResponse implements JsonResponseInterface {
|
public class UpdateResponse implements JsonResponseInterface {
|
||||||
public String dir;
|
public String dirName;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getType() {
|
public String getType() {
|
||||||
|
@ -32,6 +32,6 @@ public void execute(WebSocketService service, ChannelHandlerContext ctx, Client
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
service.sendObject(ctx, new UpdateRequestEvent(LaunchServer.server.updatesDirMap.get(dir).object, LaunchServer.server.config.netty.downloadURL.concat(dir)));
|
service.sendObject(ctx, new UpdateRequestEvent(LaunchServer.server.updatesDirMap.get(dirName).object, LaunchServer.server.config.netty.downloadURL.replace("%dirname%",dirName)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ public class ConsoleMain {
|
||||||
public static CommandHandler commandHandler;
|
public static CommandHandler commandHandler;
|
||||||
|
|
||||||
public static void main(String[] args) throws IOException {
|
public static void main(String[] args) throws IOException {
|
||||||
if (ServerWrapper.wrapper.config == null) {
|
if (ServerWrapper.wrapper.config == null) {
|
||||||
LogHelper.warning("ServerWrapper not found");
|
LogHelper.warning("ServerWrapper not found");
|
||||||
}
|
}
|
||||||
if (!ServerWrapper.wrapper.permissions.canAdmin) {
|
if (!ServerWrapper.wrapper.permissions.canAdmin) {
|
||||||
|
|
|
@ -76,14 +76,12 @@ public static final class Params extends StreamObject {
|
||||||
public final int width;
|
public final int width;
|
||||||
@LauncherAPI
|
@LauncherAPI
|
||||||
public final int height;
|
public final int height;
|
||||||
private final byte[] launcherDigest;
|
|
||||||
@LauncherAPI
|
@LauncherAPI
|
||||||
public final long session;
|
public final long session;
|
||||||
|
|
||||||
@LauncherAPI
|
@LauncherAPI
|
||||||
public Params(byte[] launcherDigest, Path assetDir, Path clientDir, PlayerProfile pp, String accessToken,
|
public Params(byte[] launcherDigest, Path assetDir, Path clientDir, PlayerProfile pp, String accessToken,
|
||||||
boolean autoEnter, boolean fullScreen, int ram, int width, int height) {
|
boolean autoEnter, boolean fullScreen, int ram, int width, int height) {
|
||||||
this.launcherDigest = launcherDigest.clone();
|
|
||||||
// Client paths
|
// Client paths
|
||||||
this.assetDir = assetDir;
|
this.assetDir = assetDir;
|
||||||
this.clientDir = clientDir;
|
this.clientDir = clientDir;
|
||||||
|
@ -100,7 +98,6 @@ public Params(byte[] launcherDigest, Path assetDir, Path clientDir, PlayerProfil
|
||||||
|
|
||||||
@LauncherAPI
|
@LauncherAPI
|
||||||
public Params(HInput input) throws Exception {
|
public Params(HInput input) throws Exception {
|
||||||
launcherDigest = input.readByteArray(0);
|
|
||||||
session = input.readLong();
|
session = input.readLong();
|
||||||
// Client paths
|
// Client paths
|
||||||
assetDir = IOHelper.toPath(input.readString(0));
|
assetDir = IOHelper.toPath(input.readString(0));
|
||||||
|
@ -119,7 +116,6 @@ public Params(HInput input) throws Exception {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void write(HOutput output) throws IOException {
|
public void write(HOutput output) throws IOException {
|
||||||
output.writeByteArray(launcherDigest, 0);
|
|
||||||
output.writeLong(session);
|
output.writeLong(session);
|
||||||
// Client paths
|
// Client paths
|
||||||
output.writeString(assetDir.toString(), 0);
|
output.writeString(assetDir.toString(), 0);
|
||||||
|
@ -454,7 +450,6 @@ public static void main(String... args) throws Throwable {
|
||||||
// Verify ClientLauncher sign and classpath
|
// Verify ClientLauncher sign and classpath
|
||||||
LogHelper.debug("Verifying ClientLauncher sign and classpath");
|
LogHelper.debug("Verifying ClientLauncher sign and classpath");
|
||||||
//Warning - experimental.
|
//Warning - experimental.
|
||||||
SecurityHelper.verifySign(LegacyLauncherRequest.BINARY_PATH, params.launcherDigest, Launcher.getConfig().publicKey);
|
|
||||||
LinkedList<Path> classPath = resolveClassPathList(params.clientDir, profile.getClassPath());
|
LinkedList<Path> classPath = resolveClassPathList(params.clientDir, profile.getClassPath());
|
||||||
for (Path classpathURL : classPath) {
|
for (Path classpathURL : classPath) {
|
||||||
LauncherAgent.addJVMClassPath(classpathURL.toAbsolutePath().toString());
|
LauncherAgent.addJVMClassPath(classpathURL.toAbsolutePath().toString());
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
import org.apache.http.impl.client.HttpClients;
|
import org.apache.http.impl.client.HttpClients;
|
||||||
import org.apache.http.impl.client.LaxRedirectStrategy;
|
import org.apache.http.impl.client.LaxRedirectStrategy;
|
||||||
import ru.gravit.utils.helper.IOHelper;
|
import ru.gravit.utils.helper.IOHelper;
|
||||||
|
import ru.gravit.utils.helper.LogHelper;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
@ -26,6 +27,7 @@ public void download(String base, List<String> applies, Path dstDirFile) throws
|
||||||
HttpGet get = null;
|
HttpGet get = null;
|
||||||
for (String apply : applies) {
|
for (String apply : applies) {
|
||||||
URI u = new URL(base.concat(apply)).toURI();
|
URI u = new URL(base.concat(apply)).toURI();
|
||||||
|
LogHelper.debug("Download URL: %s", u.toString());
|
||||||
if (get == null) get = new HttpGet(u);
|
if (get == null) get = new HttpGet(u);
|
||||||
else {
|
else {
|
||||||
get.reset();
|
get.reset();
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
import ru.gravit.launcher.serialize.SerializeLimits;
|
import ru.gravit.launcher.serialize.SerializeLimits;
|
||||||
import ru.gravit.launcher.serialize.signed.SignedObjectHolder;
|
import ru.gravit.launcher.serialize.signed.SignedObjectHolder;
|
||||||
import ru.gravit.utils.helper.IOHelper;
|
import ru.gravit.utils.helper.IOHelper;
|
||||||
|
import ru.gravit.utils.helper.LogHelper;
|
||||||
import ru.gravit.utils.helper.SecurityHelper;
|
import ru.gravit.utils.helper.SecurityHelper;
|
||||||
import ru.gravit.utils.helper.SecurityHelper.DigestAlgorithm;
|
import ru.gravit.utils.helper.SecurityHelper.DigestAlgorithm;
|
||||||
|
|
||||||
|
@ -199,7 +200,9 @@ private static void fillActionsQueue(Queue<UpdateAction> queue, HashedDir mismat
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public UpdateRequestEvent requestWebSockets() throws Exception {
|
public UpdateRequestEvent requestWebSockets() throws Exception {
|
||||||
|
LogHelper.debug("Start update request");
|
||||||
UpdateRequestEvent e = (UpdateRequestEvent) LegacyRequestBridge.sendRequest(this);
|
UpdateRequestEvent e = (UpdateRequestEvent) LegacyRequestBridge.sendRequest(this);
|
||||||
|
LogHelper.debug("Start update");
|
||||||
Launcher.profile.pushOptionalFile(e.hdir, !Launcher.profile.isUpdateFastCheck());
|
Launcher.profile.pushOptionalFile(e.hdir, !Launcher.profile.isUpdateFastCheck());
|
||||||
HashedDir.Diff diff = e.hdir.diff(localDir, matcher);
|
HashedDir.Diff diff = e.hdir.diff(localDir, matcher);
|
||||||
final List<String> adds = new ArrayList<>();
|
final List<String> adds = new ArrayList<>();
|
||||||
|
@ -207,26 +210,29 @@ public UpdateRequestEvent requestWebSockets() throws Exception {
|
||||||
adds.add(a.getKey());
|
adds.add(a.getKey());
|
||||||
});
|
});
|
||||||
totalSize = diff.mismatch.size();
|
totalSize = diff.mismatch.size();
|
||||||
|
startTime = Instant.now();
|
||||||
|
updateState("UnknownFile", 0L, 100);
|
||||||
ListDownloader listDownloader = new ListDownloader();
|
ListDownloader listDownloader = new ListDownloader();
|
||||||
listDownloader.download(e.url, adds, dir);
|
listDownloader.download(e.url, adds, dir);
|
||||||
deleteExtraDir(dir, diff.extra, diff.extra.flag);
|
deleteExtraDir(dir, diff.extra, diff.extra.flag);
|
||||||
|
LogHelper.debug("Update success");
|
||||||
return e;
|
return e;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Instance
|
// Instance
|
||||||
private final String dirName;
|
private final String dirName;
|
||||||
private final Path dir;
|
private transient final Path dir;
|
||||||
private final FileNameMatcher matcher;
|
private transient final FileNameMatcher matcher;
|
||||||
|
|
||||||
private final boolean digest;
|
private transient final boolean digest;
|
||||||
private volatile Callback stateCallback;
|
private transient volatile Callback stateCallback;
|
||||||
// State
|
// State
|
||||||
private HashedDir localDir;
|
private transient HashedDir localDir;
|
||||||
private long totalDownloaded;
|
private transient long totalDownloaded;
|
||||||
|
|
||||||
private long totalSize;
|
private transient long totalSize;
|
||||||
|
|
||||||
private Instant startTime;
|
private transient Instant startTime;
|
||||||
|
|
||||||
@LauncherAPI
|
@LauncherAPI
|
||||||
public UpdateRequest(LauncherConfig config, String dirName, Path dir, FileNameMatcher matcher, boolean digest) {
|
public UpdateRequest(LauncherConfig config, String dirName, Path dir, FileNameMatcher matcher, boolean digest) {
|
||||||
|
|
Loading…
Reference in a new issue