[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;
@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);
}
}

View file

@ -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))) {