[FIX][EXPERIMENTAL] Исправление ошибки сохранения HashedStoreEntry

This commit is contained in:
Gravit 2019-05-20 07:07:43 +07:00
parent c6389c697b
commit 69aef41e5d
2 changed files with 7 additions and 4 deletions

View file

@ -47,6 +47,8 @@ public static class HashedStoreEntry {
public String name; public String name;
@LauncherAPI @LauncherAPI
public String fullPath; public String fullPath;
@LauncherAPI
public transient boolean needSave = false;
public HashedStoreEntry(HashedDir hdir, String name, String fullPath) { public HashedStoreEntry(HashedDir hdir, String name, String fullPath) {
this.hdir = hdir; this.hdir = hdir;
@ -61,9 +63,9 @@ public HashedStoreEntry(HashedDir hdir, String name, String fullPath) {
@LauncherAPI @LauncherAPI
public void putHDir(String name, Path path, HashedDir dir) { public void putHDir(String name, Path path, HashedDir dir) {
String fullPath = path.toAbsolutePath().toString(); String fullPath = path.toAbsolutePath().toString();
for (HashedStoreEntry e : lastHDirs) { lastHDirs.removeIf((e) -> e.fullPath.equals(fullPath) && e.name.equals(name));
if (e.fullPath.equals(fullPath) && e.name.equals(name)) return; HashedStoreEntry e = new HashedStoreEntry(dir, name, fullPath);
} e.needSave = true;
lastHDirs.add(new HashedStoreEntry(dir, name, fullPath)); lastHDirs.add(e);
} }
} }

View file

@ -69,6 +69,7 @@ public void loadHDirStore(Path storePath) throws IOException {
public void saveHDirStore(Path storeProjectPath) throws IOException { public void saveHDirStore(Path storeProjectPath) throws IOException {
Files.createDirectories(storeProjectPath); Files.createDirectories(storeProjectPath);
for (NewLauncherSettings.HashedStoreEntry e : settings.lastHDirs) { for (NewLauncherSettings.HashedStoreEntry e : settings.lastHDirs) {
if(!e.needSave) continue;
Path file = storeProjectPath.resolve(e.name.concat(".bin")); Path file = storeProjectPath.resolve(e.name.concat(".bin"));
if (!Files.exists(file)) Files.createFile(file); if (!Files.exists(file)) Files.createFile(file);
try (HOutput output = new HOutput(IOHelper.newOutput(file))) { try (HOutput output = new HOutput(IOHelper.newOutput(file))) {