mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-12-23 09:01:08 +03:00
[FIX] Исправление рантайма для UpdateResponse
This commit is contained in:
parent
bcedb95eec
commit
57fc3b1c04
4 changed files with 22 additions and 17 deletions
|
@ -237,7 +237,7 @@ var digest = profile.isUpdateFastCheck();
|
||||||
makeSetProfileRequest(profile, function() {
|
makeSetProfileRequest(profile, function() {
|
||||||
ClientLauncher.setProfile(profile);
|
ClientLauncher.setProfile(profile);
|
||||||
makeUpdateRequest(assetDirName, assetDir, assetMatcher, digest, function(assetHDir) {
|
makeUpdateRequest(assetDirName, assetDir, assetMatcher, digest, function(assetHDir) {
|
||||||
settings.lastHDirs.put(assetDirName, assetHDir);
|
settings.lastHDirs.put(assetDirName, assetHDir.hdir);
|
||||||
|
|
||||||
// Update client dir
|
// Update client dir
|
||||||
update.resetOverlay("Обновление файлов клиента");
|
update.resetOverlay("Обновление файлов клиента");
|
||||||
|
@ -245,7 +245,7 @@ var digest = profile.isUpdateFastCheck();
|
||||||
var clientDir = settings.updatesDir.resolve(clientDirName);
|
var clientDir = settings.updatesDir.resolve(clientDirName);
|
||||||
var clientMatcher = profile.getClientUpdateMatcher();
|
var clientMatcher = profile.getClientUpdateMatcher();
|
||||||
makeUpdateRequest(clientDirName, clientDir, clientMatcher, digest, function(clientHDir) {
|
makeUpdateRequest(clientDirName, clientDir, clientMatcher, digest, function(clientHDir) {
|
||||||
settings.lastHDirs.put(clientDirName, clientHDir);
|
settings.lastHDirs.put(clientDirName, clientHDir.hdir);
|
||||||
doLaunchClient(assetDir, assetHDir, clientDir, clientHDir, profile, pp, accessToken);
|
doLaunchClient(assetDir, assetHDir, clientDir, clientHDir, profile, pp, accessToken);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -46,7 +46,7 @@ public class LauncherSettings {
|
||||||
@LauncherAPI
|
@LauncherAPI
|
||||||
public List<ClientProfile> lastProfiles = new LinkedList<>();
|
public List<ClientProfile> lastProfiles = new LinkedList<>();
|
||||||
@LauncherAPI
|
@LauncherAPI
|
||||||
public Map<String, SignedObjectHolder<HashedDir>> lastHDirs = new HashMap<>(16);
|
public Map<String, HashedDir> lastHDirs = new HashMap<>(16);
|
||||||
|
|
||||||
@LauncherAPI
|
@LauncherAPI
|
||||||
public void load() throws SignatureException {
|
public void load() throws SignatureException {
|
||||||
|
@ -103,7 +103,6 @@ public void read(HInput input) throws IOException, SignatureException {
|
||||||
setRAM(input.readLength(JVMHelper.RAM));
|
setRAM(input.readLength(JVMHelper.RAM));
|
||||||
|
|
||||||
// Offline cache
|
// Offline cache
|
||||||
RSAPublicKey publicKey = Launcher.getConfig().publicKey;
|
|
||||||
lastDigest = input.readBoolean() ? input.readByteArray(0) : null;
|
lastDigest = input.readBoolean() ? input.readByteArray(0) : null;
|
||||||
lastProfiles.clear();
|
lastProfiles.clear();
|
||||||
int lastProfilesCount = input.readLength(0);
|
int lastProfilesCount = input.readLength(0);
|
||||||
|
@ -114,8 +113,6 @@ public void read(HInput input) throws IOException, SignatureException {
|
||||||
int lastHDirsCount = input.readLength(0);
|
int lastHDirsCount = input.readLength(0);
|
||||||
for (int i = 0; i < lastHDirsCount; i++) {
|
for (int i = 0; i < lastHDirsCount; i++) {
|
||||||
String name = IOHelper.verifyFileName(input.readString(255));
|
String name = IOHelper.verifyFileName(input.readString(255));
|
||||||
VerifyHelper.putIfAbsent(lastHDirs, name, new SignedObjectHolder<>(input, publicKey, HashedDir::new),
|
|
||||||
java.lang.String.format("Duplicate offline hashed dir: '%s'", name));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -153,7 +150,7 @@ public void write(HOutput output) throws IOException {
|
||||||
output.writeString(Launcher.gson.toJson(profile), 0);
|
output.writeString(Launcher.gson.toJson(profile), 0);
|
||||||
}
|
}
|
||||||
output.writeLength(lastHDirs.size(), 0);
|
output.writeLength(lastHDirs.size(), 0);
|
||||||
for (Map.Entry<String, SignedObjectHolder<HashedDir>> entry : lastHDirs.entrySet()) {
|
for (Map.Entry<String, HashedDir> entry : lastHDirs.entrySet()) {
|
||||||
output.writeString(entry.getKey(), 0);
|
output.writeString(entry.getKey(), 0);
|
||||||
entry.getValue().write(output);
|
entry.getValue().write(output);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
import ru.gravit.launcher.Launcher;
|
import ru.gravit.launcher.Launcher;
|
||||||
import ru.gravit.launcher.LauncherAPI;
|
import ru.gravit.launcher.LauncherAPI;
|
||||||
import ru.gravit.launcher.LauncherConfig;
|
import ru.gravit.launcher.LauncherConfig;
|
||||||
|
import ru.gravit.launcher.events.request.UpdateRequestEvent;
|
||||||
import ru.gravit.launcher.hasher.FileNameMatcher;
|
import ru.gravit.launcher.hasher.FileNameMatcher;
|
||||||
import ru.gravit.launcher.hasher.HashedDir;
|
import ru.gravit.launcher.hasher.HashedDir;
|
||||||
import ru.gravit.launcher.hasher.HashedEntry;
|
import ru.gravit.launcher.hasher.HashedEntry;
|
||||||
|
@ -11,6 +12,8 @@
|
||||||
import ru.gravit.launcher.request.RequestType;
|
import ru.gravit.launcher.request.RequestType;
|
||||||
import ru.gravit.launcher.request.UpdateAction;
|
import ru.gravit.launcher.request.UpdateAction;
|
||||||
import ru.gravit.launcher.request.update.UpdateRequest.State.Callback;
|
import ru.gravit.launcher.request.update.UpdateRequest.State.Callback;
|
||||||
|
import ru.gravit.launcher.request.websockets.LegacyRequestBridge;
|
||||||
|
import ru.gravit.launcher.request.websockets.RequestInterface;
|
||||||
import ru.gravit.launcher.serialize.HInput;
|
import ru.gravit.launcher.serialize.HInput;
|
||||||
import ru.gravit.launcher.serialize.HOutput;
|
import ru.gravit.launcher.serialize.HOutput;
|
||||||
import ru.gravit.launcher.serialize.SerializeLimits;
|
import ru.gravit.launcher.serialize.SerializeLimits;
|
||||||
|
@ -35,7 +38,12 @@
|
||||||
import java.util.Queue;
|
import java.util.Queue;
|
||||||
import java.util.zip.InflaterInputStream;
|
import java.util.zip.InflaterInputStream;
|
||||||
|
|
||||||
public final class UpdateRequest extends Request<SignedObjectHolder<HashedDir>> {
|
public final class UpdateRequest extends Request<UpdateRequestEvent> implements RequestInterface {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getType() {
|
||||||
|
return "update";
|
||||||
|
}
|
||||||
|
|
||||||
public static final class State {
|
public static final class State {
|
||||||
@FunctionalInterface
|
@FunctionalInterface
|
||||||
|
@ -189,6 +197,11 @@ private static void fillActionsQueue(Queue<UpdateAction> queue, HashedDir mismat
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
|
public UpdateRequestEvent requestWebSockets() throws Exception
|
||||||
|
{
|
||||||
|
return (UpdateRequestEvent) LegacyRequestBridge.sendRequest(this);
|
||||||
|
}
|
||||||
|
|
||||||
// Instance
|
// Instance
|
||||||
private final String dirName;
|
private final String dirName;
|
||||||
|
@ -290,16 +303,9 @@ public Integer getLegacyType() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SignedObjectHolder<HashedDir> request() throws Exception {
|
protected UpdateRequestEvent requestDo(HInput input, HOutput output) throws IOException, SignatureException {
|
||||||
Files.createDirectories(dir);
|
Files.createDirectories(dir);
|
||||||
localDir = new HashedDir(dir, matcher, false, digest);
|
localDir = new HashedDir(dir, matcher, false, digest);
|
||||||
|
|
||||||
// Start request
|
|
||||||
return super.request();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected SignedObjectHolder<HashedDir> requestDo(HInput input, HOutput output) throws IOException, SignatureException {
|
|
||||||
// Write update dir name
|
// Write update dir name
|
||||||
output.writeString(dirName, 255);
|
output.writeString(dirName, 255);
|
||||||
output.flush();
|
output.flush();
|
||||||
|
@ -365,7 +371,7 @@ protected SignedObjectHolder<HashedDir> requestDo(HInput input, HOutput output)
|
||||||
|
|
||||||
// Write update completed packet
|
// Write update completed packet
|
||||||
deleteExtraDir(dir, diff.extra, diff.extra.flag);
|
deleteExtraDir(dir, diff.extra, diff.extra.flag);
|
||||||
return remoteHDirHolder;
|
return new UpdateRequestEvent(remoteHDirHolder.object);
|
||||||
}
|
}
|
||||||
|
|
||||||
@LauncherAPI
|
@LauncherAPI
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
package ru.gravit.launcher.events.request;
|
package ru.gravit.launcher.events.request;
|
||||||
|
|
||||||
|
import ru.gravit.launcher.LauncherNetworkAPI;
|
||||||
import ru.gravit.launcher.hasher.HashedDir;
|
import ru.gravit.launcher.hasher.HashedDir;
|
||||||
import ru.gravit.launcher.request.ResultInterface;
|
import ru.gravit.launcher.request.ResultInterface;
|
||||||
|
|
||||||
public class UpdateRequestEvent implements ResultInterface {
|
public class UpdateRequestEvent implements ResultInterface {
|
||||||
|
@LauncherNetworkAPI
|
||||||
public HashedDir hdir;
|
public HashedDir hdir;
|
||||||
@Override
|
@Override
|
||||||
public String getType() {
|
public String getType() {
|
||||||
|
|
Loading…
Reference in a new issue