mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-11-15 11:39:11 +03:00
[FIX] Выключен старый костыль и включено использование флага
This commit is contained in:
parent
1e77d6cc66
commit
ac9ff4918a
3 changed files with 13 additions and 18 deletions
|
@ -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)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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)) {
|
||||||
HashedFile file = (HashedFile) entry;
|
if(!entry.flag)
|
||||||
totalSize += file.size;
|
{
|
||||||
adds.add(new ListDownloader.DownloadTask(path, file.size));
|
HashedFile file = (HashedFile) entry;
|
||||||
|
totalSize += 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));
|
||||||
|
|
Loading…
Reference in a new issue