From 477798e30ca7c12a264ae1468e2bc81ea0c2afe4 Mon Sep 17 00:00:00 2001 From: Gravit Date: Sun, 14 Apr 2019 00:15:12 +0700 Subject: [PATCH] =?UTF-8?q?[FIX]=20=D0=A0=D0=B0=D1=81=D1=88=D0=B8=D1=80?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=BB=D0=BE=D0=B3=D0=B8=D0=BA=D0=B8?= =?UTF-8?q?=20HashedDirStore?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Launcher/runtime/dialog/dialog.js | 4 +-- .../runtime/dialog/overlay/update/update.js | 13 ++++---- .../gravit/launcher/NewLauncherSettings.java | 32 ++++++++++++++++--- .../launcher/managers/SettingsManager.java | 12 +++---- 4 files changed, 42 insertions(+), 19 deletions(-) diff --git a/Launcher/runtime/dialog/dialog.js b/Launcher/runtime/dialog/dialog.js index 676aa840..cc320481 100644 --- a/Launcher/runtime/dialog/dialog.js +++ b/Launcher/runtime/dialog/dialog.js @@ -264,14 +264,14 @@ function doUpdate(profile, pp, accessToken) { makeSetProfileRequest(profile, function() { ClientLauncher.setProfile(profile); makeUpdateRequest(assetDirName, assetDir, assetMatcher, digest, function(assetHDir) { - settings.lastHDirs.put(assetDirName, assetHDir.hdir); + settings.putHDir(assetDirName, assetDir, assetHDir.hdir); update.resetOverlay("Обновление файлов клиента"); var clientDirName = profile.getDir(); var clientDir = settings.updatesDir.resolve(clientDirName); var clientMatcher = profile.getClientUpdateMatcher(); makeUpdateRequest(clientDirName, clientDir, clientMatcher, digest, function(clientHDir) { - settings.lastHDirs.put(clientDirName, clientHDir.hdir); + settings.putHDir(clientDirName, clientDir, clientHDir.hdir); doLaunchClient(assetDir, assetHDir.hdir, clientDir, clientHDir.hdir, profile, pp, accessToken); }); }); diff --git a/Launcher/runtime/dialog/overlay/update/update.js b/Launcher/runtime/dialog/overlay/update/update.js index 297f85a6..da013488 100644 --- a/Launcher/runtime/dialog/overlay/update/update.js +++ b/Launcher/runtime/dialog/overlay/update/update.js @@ -67,13 +67,14 @@ var update = { function offlineUpdateRequest(dirName, dir, matcher, digest) { return function() { - var hdir = settings.lastHDirs.get(dirName); - if (hdir === null) { - Request.requestError(java.lang.String.format("Директории '%s' нет в кэше", dirName)); - return; - } + LogHelper.error("Unsupported operation"); + //var hdir = settings.lastHDirs.get(dirName); + //if (hdir === null) { + // Request.requestError(java.lang.String.format("Директории '%s' нет в кэше", dirName)); + // return; + //} - return FunctionalBridge.offlineUpdateRequest(dir, hdir, matcher, digest).run(); + //return FunctionalBridge.offlineUpdateRequest(dir, hdir, matcher, digest).run(); }; } diff --git a/Launcher/src/main/java/ru/gravit/launcher/NewLauncherSettings.java b/Launcher/src/main/java/ru/gravit/launcher/NewLauncherSettings.java index 4cbab087..3f7f43bf 100644 --- a/Launcher/src/main/java/ru/gravit/launcher/NewLauncherSettings.java +++ b/Launcher/src/main/java/ru/gravit/launcher/NewLauncherSettings.java @@ -4,10 +4,7 @@ import ru.gravit.launcher.profiles.ClientProfile; import java.nio.file.Path; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; +import java.util.*; public class NewLauncherSettings { @LauncherAPI @@ -33,6 +30,31 @@ public class NewLauncherSettings { public byte[] lastDigest; @LauncherAPI public List lastProfiles = new LinkedList<>(); + public static class HashedStoreEntry + { + @LauncherAPI + public HashedDir hdir; + @LauncherAPI + public String name; + @LauncherAPI + public String fullPath; + + public HashedStoreEntry(HashedDir hdir, String name, String fullPath) { + this.hdir = hdir; + this.name = name; + this.fullPath = fullPath; + } + } @LauncherAPI - public transient Map lastHDirs = new HashMap<>(16); + public transient List lastHDirs = new ArrayList<>(16); + @LauncherAPI + public void putHDir(String name, Path path, HashedDir dir) + { + String fullPath = path.toAbsolutePath().toString(); + for(HashedStoreEntry e : lastHDirs) + { + if(e.fullPath.equals(fullPath) && e.name.equals(name)) return; + } + lastHDirs.add(new HashedStoreEntry(dir, name, fullPath)); + } } diff --git a/Launcher/src/main/java/ru/gravit/launcher/managers/SettingsManager.java b/Launcher/src/main/java/ru/gravit/launcher/managers/SettingsManager.java index 6e04378b..0865e2c9 100644 --- a/Launcher/src/main/java/ru/gravit/launcher/managers/SettingsManager.java +++ b/Launcher/src/main/java/ru/gravit/launcher/managers/SettingsManager.java @@ -27,7 +27,7 @@ public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) String dirName = input.readString(128); String fullPath = input.readString(1024); HashedDir dir = new HashedDir(input); - settings.lastHDirs.put(dirName, dir); + settings.lastHDirs.add(new NewLauncherSettings.HashedStoreEntry(dir, dirName, fullPath)); } return super.visitFile(file, attrs); } @@ -68,14 +68,14 @@ public void loadHDirStore(Path storePath) throws IOException public void saveHDirStore(Path storeProjectPath) throws IOException { Files.createDirectories(storeProjectPath); - for(Map.Entry e : settings.lastHDirs.entrySet()) + for(NewLauncherSettings.HashedStoreEntry e : settings.lastHDirs) { - Path file = Files.createFile(storeProjectPath.resolve(e.getKey().concat(".bin"))); + Path file = Files.createFile(storeProjectPath.resolve(e.name.concat(".bin"))); try(HOutput output = new HOutput(IOHelper.newOutput(file))) { - output.writeString(e.getKey(), 128); - output.writeString("", 1024); - e.getValue().write(output); + output.writeString(e.name, 128); + output.writeString(e.fullPath, 1024); + e.hdir.write(output); } } }