From 69aef41e5df3d5442d6294bb9a3ba3403b7bc862 Mon Sep 17 00:00:00 2001 From: Gravit Date: Mon, 20 May 2019 07:07:43 +0700 Subject: [PATCH] =?UTF-8?q?[FIX][EXPERIMENTAL]=20=D0=98=D1=81=D0=BF=D1=80?= =?UTF-8?q?=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=BE=D1=88=D0=B8?= =?UTF-8?q?=D0=B1=D0=BA=D0=B8=20=D1=81=D0=BE=D1=85=D1=80=D0=B0=D0=BD=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D1=8F=20HashedStoreEntry?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/ru/gravit/launcher/NewLauncherSettings.java | 10 ++++++---- .../ru/gravit/launcher/managers/SettingsManager.java | 1 + 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/Launcher/src/main/java/ru/gravit/launcher/NewLauncherSettings.java b/Launcher/src/main/java/ru/gravit/launcher/NewLauncherSettings.java index 8ebde57c..241b792f 100644 --- a/Launcher/src/main/java/ru/gravit/launcher/NewLauncherSettings.java +++ b/Launcher/src/main/java/ru/gravit/launcher/NewLauncherSettings.java @@ -47,6 +47,8 @@ public static class HashedStoreEntry { public String name; @LauncherAPI public String fullPath; + @LauncherAPI + public transient boolean needSave = false; public HashedStoreEntry(HashedDir hdir, String name, String fullPath) { this.hdir = hdir; @@ -61,9 +63,9 @@ public HashedStoreEntry(HashedDir hdir, String name, String fullPath) { @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)); + lastHDirs.removeIf((e) -> e.fullPath.equals(fullPath) && e.name.equals(name)); + HashedStoreEntry e = new HashedStoreEntry(dir, name, fullPath); + e.needSave = true; + lastHDirs.add(e); } } 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 61d05238..6bd53aca 100644 --- a/Launcher/src/main/java/ru/gravit/launcher/managers/SettingsManager.java +++ b/Launcher/src/main/java/ru/gravit/launcher/managers/SettingsManager.java @@ -69,6 +69,7 @@ public void loadHDirStore(Path storePath) throws IOException { public void saveHDirStore(Path storeProjectPath) throws IOException { Files.createDirectories(storeProjectPath); for (NewLauncherSettings.HashedStoreEntry e : settings.lastHDirs) { + if(!e.needSave) continue; Path file = storeProjectPath.resolve(e.name.concat(".bin")); if (!Files.exists(file)) Files.createFile(file); try (HOutput output = new HOutput(IOHelper.newOutput(file))) {