From 57fc3b1c04651b8e802f180dbeea62a46346624f Mon Sep 17 00:00:00 2001 From: Gravit Date: Wed, 20 Feb 2019 17:11:42 +0700 Subject: [PATCH] =?UTF-8?q?[FIX]=20=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2?= =?UTF-8?q?=D0=BB=D0=B5=D0=BD=D0=B8=D0=B5=20=D1=80=D0=B0=D0=BD=D1=82=D0=B0?= =?UTF-8?q?=D0=B9=D0=BC=D0=B0=20=D0=B4=D0=BB=D1=8F=20UpdateResponse?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Launcher/runtime/dialog/dialog.js | 4 +-- .../launcher/client/LauncherSettings.java | 7 ++--- .../request/update/UpdateRequest.java | 26 ++++++++++++------- .../events/request/UpdateRequestEvent.java | 2 ++ 4 files changed, 22 insertions(+), 17 deletions(-) diff --git a/Launcher/runtime/dialog/dialog.js b/Launcher/runtime/dialog/dialog.js index 3007dea9..673e0570 100644 --- a/Launcher/runtime/dialog/dialog.js +++ b/Launcher/runtime/dialog/dialog.js @@ -237,7 +237,7 @@ var digest = profile.isUpdateFastCheck(); makeSetProfileRequest(profile, function() { ClientLauncher.setProfile(profile); makeUpdateRequest(assetDirName, assetDir, assetMatcher, digest, function(assetHDir) { - settings.lastHDirs.put(assetDirName, assetHDir); + settings.lastHDirs.put(assetDirName, assetHDir.hdir); // Update client dir update.resetOverlay("Обновление файлов клиента"); @@ -245,7 +245,7 @@ var digest = profile.isUpdateFastCheck(); var clientDir = settings.updatesDir.resolve(clientDirName); var clientMatcher = profile.getClientUpdateMatcher(); 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); }); }); diff --git a/Launcher/src/main/java/ru/gravit/launcher/client/LauncherSettings.java b/Launcher/src/main/java/ru/gravit/launcher/client/LauncherSettings.java index 1921204c..be8938b8 100644 --- a/Launcher/src/main/java/ru/gravit/launcher/client/LauncherSettings.java +++ b/Launcher/src/main/java/ru/gravit/launcher/client/LauncherSettings.java @@ -46,7 +46,7 @@ public class LauncherSettings { @LauncherAPI public List lastProfiles = new LinkedList<>(); @LauncherAPI - public Map> lastHDirs = new HashMap<>(16); + public Map lastHDirs = new HashMap<>(16); @LauncherAPI public void load() throws SignatureException { @@ -103,7 +103,6 @@ public void read(HInput input) throws IOException, SignatureException { setRAM(input.readLength(JVMHelper.RAM)); // Offline cache - RSAPublicKey publicKey = Launcher.getConfig().publicKey; lastDigest = input.readBoolean() ? input.readByteArray(0) : null; lastProfiles.clear(); int lastProfilesCount = input.readLength(0); @@ -114,8 +113,6 @@ public void read(HInput input) throws IOException, SignatureException { int lastHDirsCount = input.readLength(0); for (int i = 0; i < lastHDirsCount; i++) { 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.writeLength(lastHDirs.size(), 0); - for (Map.Entry> entry : lastHDirs.entrySet()) { + for (Map.Entry entry : lastHDirs.entrySet()) { output.writeString(entry.getKey(), 0); entry.getValue().write(output); } diff --git a/LauncherAPI/src/main/java/ru/gravit/launcher/request/update/UpdateRequest.java b/LauncherAPI/src/main/java/ru/gravit/launcher/request/update/UpdateRequest.java index 687c656a..80352243 100644 --- a/LauncherAPI/src/main/java/ru/gravit/launcher/request/update/UpdateRequest.java +++ b/LauncherAPI/src/main/java/ru/gravit/launcher/request/update/UpdateRequest.java @@ -3,6 +3,7 @@ import ru.gravit.launcher.Launcher; import ru.gravit.launcher.LauncherAPI; import ru.gravit.launcher.LauncherConfig; +import ru.gravit.launcher.events.request.UpdateRequestEvent; import ru.gravit.launcher.hasher.FileNameMatcher; import ru.gravit.launcher.hasher.HashedDir; import ru.gravit.launcher.hasher.HashedEntry; @@ -11,6 +12,8 @@ import ru.gravit.launcher.request.RequestType; import ru.gravit.launcher.request.UpdateAction; 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.HOutput; import ru.gravit.launcher.serialize.SerializeLimits; @@ -35,7 +38,12 @@ import java.util.Queue; import java.util.zip.InflaterInputStream; -public final class UpdateRequest extends Request> { +public final class UpdateRequest extends Request implements RequestInterface { + + @Override + public String getType() { + return "update"; + } public static final class State { @FunctionalInterface @@ -189,6 +197,11 @@ private static void fillActionsQueue(Queue queue, HashedDir mismat } } } + @Override + public UpdateRequestEvent requestWebSockets() throws Exception + { + return (UpdateRequestEvent) LegacyRequestBridge.sendRequest(this); + } // Instance private final String dirName; @@ -290,16 +303,9 @@ public Integer getLegacyType() { } @Override - public SignedObjectHolder request() throws Exception { + protected UpdateRequestEvent requestDo(HInput input, HOutput output) throws IOException, SignatureException { Files.createDirectories(dir); localDir = new HashedDir(dir, matcher, false, digest); - - // Start request - return super.request(); - } - - @Override - protected SignedObjectHolder requestDo(HInput input, HOutput output) throws IOException, SignatureException { // Write update dir name output.writeString(dirName, 255); output.flush(); @@ -365,7 +371,7 @@ protected SignedObjectHolder requestDo(HInput input, HOutput output) // Write update completed packet deleteExtraDir(dir, diff.extra, diff.extra.flag); - return remoteHDirHolder; + return new UpdateRequestEvent(remoteHDirHolder.object); } @LauncherAPI diff --git a/libLauncher/src/main/java/ru/gravit/launcher/events/request/UpdateRequestEvent.java b/libLauncher/src/main/java/ru/gravit/launcher/events/request/UpdateRequestEvent.java index 122db396..7829b48e 100644 --- a/libLauncher/src/main/java/ru/gravit/launcher/events/request/UpdateRequestEvent.java +++ b/libLauncher/src/main/java/ru/gravit/launcher/events/request/UpdateRequestEvent.java @@ -1,9 +1,11 @@ package ru.gravit.launcher.events.request; +import ru.gravit.launcher.LauncherNetworkAPI; import ru.gravit.launcher.hasher.HashedDir; import ru.gravit.launcher.request.ResultInterface; public class UpdateRequestEvent implements ResultInterface { + @LauncherNetworkAPI public HashedDir hdir; @Override public String getType() {