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;
|
||||
|
||||
public class UpdateResponse implements JsonResponseInterface {
|
||||
public String dir;
|
||||
public String dirName;
|
||||
|
||||
@Override
|
||||
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)));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -76,14 +76,12 @@ public static final class Params extends StreamObject {
|
|||
public final int width;
|
||||
@LauncherAPI
|
||||
public final int height;
|
||||
private final byte[] launcherDigest;
|
||||
@LauncherAPI
|
||||
public final long session;
|
||||
|
||||
@LauncherAPI
|
||||
public Params(byte[] launcherDigest, Path assetDir, Path clientDir, PlayerProfile pp, String accessToken,
|
||||
boolean autoEnter, boolean fullScreen, int ram, int width, int height) {
|
||||
this.launcherDigest = launcherDigest.clone();
|
||||
// Client paths
|
||||
this.assetDir = assetDir;
|
||||
this.clientDir = clientDir;
|
||||
|
@ -100,7 +98,6 @@ public Params(byte[] launcherDigest, Path assetDir, Path clientDir, PlayerProfil
|
|||
|
||||
@LauncherAPI
|
||||
public Params(HInput input) throws Exception {
|
||||
launcherDigest = input.readByteArray(0);
|
||||
session = input.readLong();
|
||||
// Client paths
|
||||
assetDir = IOHelper.toPath(input.readString(0));
|
||||
|
@ -119,7 +116,6 @@ public Params(HInput input) throws Exception {
|
|||
|
||||
@Override
|
||||
public void write(HOutput output) throws IOException {
|
||||
output.writeByteArray(launcherDigest, 0);
|
||||
output.writeLong(session);
|
||||
// Client paths
|
||||
output.writeString(assetDir.toString(), 0);
|
||||
|
@ -454,7 +450,6 @@ public static void main(String... args) throws Throwable {
|
|||
// Verify ClientLauncher sign and classpath
|
||||
LogHelper.debug("Verifying ClientLauncher sign and classpath");
|
||||
//Warning - experimental.
|
||||
SecurityHelper.verifySign(LegacyLauncherRequest.BINARY_PATH, params.launcherDigest, Launcher.getConfig().publicKey);
|
||||
LinkedList<Path> classPath = resolveClassPathList(params.clientDir, profile.getClassPath());
|
||||
for (Path classpathURL : classPath) {
|
||||
LauncherAgent.addJVMClassPath(classpathURL.toAbsolutePath().toString());
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
import org.apache.http.impl.client.HttpClients;
|
||||
import org.apache.http.impl.client.LaxRedirectStrategy;
|
||||
import ru.gravit.utils.helper.IOHelper;
|
||||
import ru.gravit.utils.helper.LogHelper;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
@ -26,6 +27,7 @@ public void download(String base, List<String> applies, Path dstDirFile) throws
|
|||
HttpGet get = null;
|
||||
for (String apply : applies) {
|
||||
URI u = new URL(base.concat(apply)).toURI();
|
||||
LogHelper.debug("Download URL: %s", u.toString());
|
||||
if (get == null) get = new HttpGet(u);
|
||||
else {
|
||||
get.reset();
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
import ru.gravit.launcher.serialize.SerializeLimits;
|
||||
import ru.gravit.launcher.serialize.signed.SignedObjectHolder;
|
||||
import ru.gravit.utils.helper.IOHelper;
|
||||
import ru.gravit.utils.helper.LogHelper;
|
||||
import ru.gravit.utils.helper.SecurityHelper;
|
||||
import ru.gravit.utils.helper.SecurityHelper.DigestAlgorithm;
|
||||
|
||||
|
@ -199,7 +200,9 @@ private static void fillActionsQueue(Queue<UpdateAction> queue, HashedDir mismat
|
|||
|
||||
@Override
|
||||
public UpdateRequestEvent requestWebSockets() throws Exception {
|
||||
LogHelper.debug("Start update request");
|
||||
UpdateRequestEvent e = (UpdateRequestEvent) LegacyRequestBridge.sendRequest(this);
|
||||
LogHelper.debug("Start update");
|
||||
Launcher.profile.pushOptionalFile(e.hdir, !Launcher.profile.isUpdateFastCheck());
|
||||
HashedDir.Diff diff = e.hdir.diff(localDir, matcher);
|
||||
final List<String> adds = new ArrayList<>();
|
||||
|
@ -207,26 +210,29 @@ public UpdateRequestEvent requestWebSockets() throws Exception {
|
|||
adds.add(a.getKey());
|
||||
});
|
||||
totalSize = diff.mismatch.size();
|
||||
startTime = Instant.now();
|
||||
updateState("UnknownFile", 0L, 100);
|
||||
ListDownloader listDownloader = new ListDownloader();
|
||||
listDownloader.download(e.url, adds, dir);
|
||||
deleteExtraDir(dir, diff.extra, diff.extra.flag);
|
||||
LogHelper.debug("Update success");
|
||||
return e;
|
||||
}
|
||||
|
||||
// Instance
|
||||
private final String dirName;
|
||||
private final Path dir;
|
||||
private final FileNameMatcher matcher;
|
||||
private transient final Path dir;
|
||||
private transient final FileNameMatcher matcher;
|
||||
|
||||
private final boolean digest;
|
||||
private volatile Callback stateCallback;
|
||||
private transient final boolean digest;
|
||||
private transient volatile Callback stateCallback;
|
||||
// State
|
||||
private HashedDir localDir;
|
||||
private long totalDownloaded;
|
||||
private transient HashedDir localDir;
|
||||
private transient long totalDownloaded;
|
||||
|
||||
private long totalSize;
|
||||
private transient long totalSize;
|
||||
|
||||
private Instant startTime;
|
||||
private transient Instant startTime;
|
||||
|
||||
@LauncherAPI
|
||||
public UpdateRequest(LauncherConfig config, String dirName, Path dir, FileNameMatcher matcher, boolean digest) {
|
||||
|
|
Loading…
Reference in a new issue