[FIX][EXPERIMENTAL] Некорректная работа findRecursive при отсутствии конечного HashedEntry

This commit is contained in:
Gravit 2020-09-12 15:57:03 +07:00
parent b2a3e5672a
commit 2271b91653
No known key found for this signature in database
GPG key ID: 98A079490768CCE5
2 changed files with 7 additions and 0 deletions

View file

@ -1,6 +1,7 @@
package pro.gravit.launcher.profiles.optional.actions; package pro.gravit.launcher.profiles.optional.actions;
import pro.gravit.launcher.hasher.HashedDir; import pro.gravit.launcher.hasher.HashedDir;
import pro.gravit.utils.helper.LogHelper;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -13,7 +14,9 @@ public void injectToHashedDir(HashedDir dir)
files.forEach((k,v) -> { files.forEach((k,v) -> {
HashedDir.FindRecursiveResult firstPath = dir.findRecursive(k); HashedDir.FindRecursiveResult firstPath = dir.findRecursive(k);
if (v != null && !v.isEmpty()) { if (v != null && !v.isEmpty()) {
LogHelper.dev("Debug findRecursive: name %s, parent: ", firstPath.name, firstPath.parent == null ? "null" : "not null", firstPath.entry == null ? "null" : "not null");
HashedDir.FindRecursiveResult secondPath = dir.findRecursive(v); HashedDir.FindRecursiveResult secondPath = dir.findRecursive(v);
LogHelper.dev("Debug findRecursive: name %s, parent: ", secondPath.name, secondPath.parent == null ? "null" : "not null", secondPath.entry == null ? "null" : "not null");
firstPath.parent.moveTo(firstPath.name, secondPath.parent, secondPath.name); firstPath.parent.moveTo(firstPath.name, secondPath.parent, secondPath.name);
} }
}); });

View file

@ -126,6 +126,10 @@ public FindRecursiveResult findRecursive(String path)
while (t.hasMoreTokens()) { while (t.hasMoreTokens()) {
name = t.nextToken(); name = t.nextToken();
HashedEntry e = current.map.get(name); HashedEntry e = current.map.get(name);
if(e == null && !t.hasMoreTokens())
{
break;
}
if (e.getType() == Type.DIR) { if (e.getType() == Type.DIR) {
if(!t.hasMoreTokens()) { if(!t.hasMoreTokens()) {
entry = e; entry = e;