[FIX] Выключен старый костыль и включено использование флага

This commit is contained in:
Gravit 2019-05-21 04:16:50 +07:00
parent 1e77d6cc66
commit ac9ff4918a
3 changed files with 13 additions and 18 deletions

View file

@ -5,7 +5,6 @@
import ru.gravit.launcher.gui.JSRuntimeProvider; import ru.gravit.launcher.gui.JSRuntimeProvider;
import ru.gravit.launcher.hasher.FileNameMatcher; import ru.gravit.launcher.hasher.FileNameMatcher;
import ru.gravit.launcher.hasher.HashedDir; import ru.gravit.launcher.hasher.HashedDir;
import ru.gravit.launcher.hasher.HashedEntry;
import ru.gravit.launcher.managers.ClientGsonManager; import ru.gravit.launcher.managers.ClientGsonManager;
import ru.gravit.launcher.profiles.ClientProfile; import ru.gravit.launcher.profiles.ClientProfile;
import ru.gravit.launcher.profiles.PlayerProfile; import ru.gravit.launcher.profiles.PlayerProfile;
@ -22,7 +21,6 @@
import ru.gravit.utils.helper.JVMHelper.OS; import ru.gravit.utils.helper.JVMHelper.OS;
import javax.swing.*; import javax.swing.*;
import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.lang.ProcessBuilder.Redirect; import java.lang.ProcessBuilder.Redirect;
import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodHandle;
@ -38,7 +36,6 @@
import java.nio.file.attribute.BasicFileAttributes; import java.nio.file.attribute.BasicFileAttributes;
import java.nio.file.attribute.PosixFilePermission; import java.nio.file.attribute.PosixFilePermission;
import java.util.*; import java.util.*;
import java.util.concurrent.atomic.AtomicBoolean;
public final class ClientLauncher { public final class ClientLauncher {
private static final class ClassPathFileVisitor extends SimpleFileVisitor<Path> { private static final class ClassPathFileVisitor extends SimpleFileVisitor<Path> {
@ -545,18 +542,16 @@ public static void verifyHDir(Path dir, HashedDir hdir, FileNameMatcher matcher,
HashedDir currentHDir = new HashedDir(dir, matcher, true, digest); HashedDir currentHDir = new HashedDir(dir, matcher, true, digest);
HashedDir.Diff diff = hdir.diff(currentHDir, matcher); HashedDir.Diff diff = hdir.diff(currentHDir, matcher);
if (!diff.isSame()) { if (!diff.isSame()) {
AtomicBoolean isFoundFile = new AtomicBoolean(false); /*AtomicBoolean isFoundFile = new AtomicBoolean(false);
diff.extra.walk(File.separator, (e,k,v) -> { diff.extra.walk(File.separator, (e,k,v) -> {
if(v.getType().equals(HashedEntry.Type.FILE)) { LogHelper.error("Extra file %s", e); isFoundFile.set(true); } if(v.getType().equals(HashedEntry.Type.FILE)) { LogHelper.error("Extra file %s", e); isFoundFile.set(true); }
//else LogHelper.error("Extra %s", e); else LogHelper.error("Extra %s", e);
return HashedDir.WalkAction.CONTINUE;
}); });
diff.mismatch.walk(File.separator, (e, k, v) -> { diff.mismatch.walk(File.separator, (e,k,v) -> {
if(v.getType().equals(HashedEntry.Type.FILE)) { LogHelper.error("Mismatch file %s", e); isFoundFile.set(true); } if(v.getType().equals(HashedEntry.Type.FILE)) { LogHelper.error("Mismatch file %s", e); isFoundFile.set(true); }
//else LogHelper.error("Mismatch %s", e); else LogHelper.error("Mismatch %s", e);
return HashedDir.WalkAction.CONTINUE;
}); });
if(isFoundFile.get()) if(isFoundFile.get())*/
throw new SecurityException(String.format("Forbidden modification: '%s'", IOHelper.getFileName(dir))); throw new SecurityException(String.format("Forbidden modification: '%s'", IOHelper.getFileName(dir)));
} }
} }

View file

@ -87,15 +87,12 @@ public void postDiff(UpdateRequest request, UpdateRequestEvent e, HashedDir.Diff
{ {
IOHelper.transfer(input, source); IOHelper.transfer(input, source);
} }
removed.add(path.replace('\\', '/')); entry.flag = true;
//removed.add(path.replace('\\', '/'));
} }
} }
return HashedDir.WalkAction.CONTINUE; return HashedDir.WalkAction.CONTINUE;
}); });
for(String rem : removed)
{
diff.mismatch.removeR(rem);
}
} }
} }
public Path tryFind(NewLauncherSettings.HashedStoreEntry en, HashedFile file) throws IOException public Path tryFind(NewLauncherSettings.HashedStoreEntry en, HashedFile file) throws IOException

View file

@ -194,9 +194,12 @@ public UpdateRequestEvent requestDo(StandartClientWebSocketService service) thro
if(controller != null) controller.preDownload(this, e, adds); if(controller != null) controller.preDownload(this, e, adds);
diff.mismatch.walk(IOHelper.CROSS_SEPARATOR, (path, name, entry) -> { diff.mismatch.walk(IOHelper.CROSS_SEPARATOR, (path, name, entry) -> {
if (entry.getType().equals(HashedEntry.Type.FILE)) { if (entry.getType().equals(HashedEntry.Type.FILE)) {
if(!entry.flag)
{
HashedFile file = (HashedFile) entry; HashedFile file = (HashedFile) entry;
totalSize += file.size; totalSize += file.size;
adds.add(new ListDownloader.DownloadTask(path, file.size)); adds.add(new ListDownloader.DownloadTask(path, file.size));
}
} else if (entry.getType().equals(HashedEntry.Type.DIR)) { } else if (entry.getType().equals(HashedEntry.Type.DIR)) {
try { try {
Files.createDirectories(dir.resolve(path)); Files.createDirectories(dir.resolve(path));