mirror of
https://github.com/GravitLauncher/Launcher
synced 2025-04-19 22:43:04 +03:00
[FEATURE][EXP] Отключение загрузки файлов через zip.
This commit is contained in:
parent
e4bcda5b3b
commit
07569265b7
5 changed files with 14 additions and 3 deletions
|
@ -163,6 +163,7 @@ public AuthProviderPair getAuthProviderPair() {
|
||||||
public boolean enabledRadon;
|
public boolean enabledRadon;
|
||||||
public boolean stripLineNumbers;
|
public boolean stripLineNumbers;
|
||||||
public boolean deleteTempFiles;
|
public boolean deleteTempFiles;
|
||||||
|
public boolean zipDownload;
|
||||||
|
|
||||||
public String startScript;
|
public String startScript;
|
||||||
|
|
||||||
|
@ -768,6 +769,7 @@ private void generateConfigIfNotExists(boolean testEnv) throws IOException {
|
||||||
newConfig.stripLineNumbers = true;
|
newConfig.stripLineNumbers = true;
|
||||||
newConfig.deleteTempFiles = true;
|
newConfig.deleteTempFiles = true;
|
||||||
newConfig.isWarningMissArchJava = true;
|
newConfig.isWarningMissArchJava = true;
|
||||||
|
newConfig.zipDownload = true;
|
||||||
|
|
||||||
newConfig.components = new HashMap<>();
|
newConfig.components = new HashMap<>();
|
||||||
AuthLimiterComponent authLimiterComponent = new AuthLimiterComponent();
|
AuthLimiterComponent authLimiterComponent = new AuthLimiterComponent();
|
||||||
|
@ -880,7 +882,7 @@ public void syncProfilesDir() throws IOException {
|
||||||
|
|
||||||
public void syncUpdatesDir(Collection<String> dirs) throws IOException {
|
public void syncUpdatesDir(Collection<String> dirs) throws IOException {
|
||||||
LogHelper.info("Syncing updates dir");
|
LogHelper.info("Syncing updates dir");
|
||||||
boolean start = updatesDirMap == null;
|
boolean work = updatesDirMap != null;
|
||||||
Map<String, SignedObjectHolder<HashedDir>> newUpdatesDirMap = new HashMap<>(16);
|
Map<String, SignedObjectHolder<HashedDir>> newUpdatesDirMap = new HashMap<>(16);
|
||||||
try (DirectoryStream<Path> dirStream = Files.newDirectoryStream(updatesDir)) {
|
try (DirectoryStream<Path> dirStream = Files.newDirectoryStream(updatesDir)) {
|
||||||
for (final Path updateDir : dirStream) {
|
for (final Path updateDir : dirStream) {
|
||||||
|
@ -906,7 +908,7 @@ public void syncUpdatesDir(Collection<String> dirs) throws IOException {
|
||||||
// Sync and sign update dir
|
// Sync and sign update dir
|
||||||
LogHelper.info("Syncing '%s' update dir", name);
|
LogHelper.info("Syncing '%s' update dir", name);
|
||||||
HashedDir updateHDir = new HashedDir(updateDir, null, true, true);
|
HashedDir updateHDir = new HashedDir(updateDir, null, true, true);
|
||||||
if (!start) processUpdate(updateDir, updateHDir, name);
|
if (work && config.zipDownload) processUpdate(updateDir, updateHDir, name);
|
||||||
newUpdatesDirMap.put(name, new SignedObjectHolder<>(updateHDir, privateKey));
|
newUpdatesDirMap.put(name, new SignedObjectHolder<>(updateHDir, privateKey));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -134,6 +134,12 @@ public void setWarningMissArchJava(boolean b) {
|
||||||
body.append(";");
|
body.append(";");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setIsUseBetterUpdate(boolean b) {
|
||||||
|
body.append("this.isUseBetterUpdate = ");
|
||||||
|
body.append(b ? "true" : "false");
|
||||||
|
body.append(";");
|
||||||
|
}
|
||||||
|
|
||||||
public void setGuardLicense(String name, String key, String encryptKey) {
|
public void setGuardLicense(String name, String key, String encryptKey) {
|
||||||
body.append("this.guardLicenseName = \"");
|
body.append("this.guardLicenseName = \"");
|
||||||
body.append(name);
|
body.append(name);
|
||||||
|
|
|
@ -137,6 +137,7 @@ public Path process(Path inputJar) throws IOException {
|
||||||
jaConfigurator.setGuardType(server.config.launcher.guardType);
|
jaConfigurator.setGuardType(server.config.launcher.guardType);
|
||||||
jaConfigurator.setWarningMissArchJava(server.config.isWarningMissArchJava);
|
jaConfigurator.setWarningMissArchJava(server.config.isWarningMissArchJava);
|
||||||
jaConfigurator.setEnv(server.config.env);
|
jaConfigurator.setEnv(server.config.env);
|
||||||
|
jaConfigurator.setIsUseBetterUpdate(server.config.zipDownload);
|
||||||
if (server.runtime.oemUnlockKey == null) server.runtime.oemUnlockKey = SecurityHelper.randomStringToken();
|
if (server.runtime.oemUnlockKey == null) server.runtime.oemUnlockKey = SecurityHelper.randomStringToken();
|
||||||
jaConfigurator.setOemUnlockKey(server.runtime.oemUnlockKey);
|
jaConfigurator.setOemUnlockKey(server.runtime.oemUnlockKey);
|
||||||
server.buildHookManager.registerAllClientModuleClass(jaConfigurator);
|
server.buildHookManager.registerAllClientModuleClass(jaConfigurator);
|
||||||
|
|
|
@ -6,6 +6,7 @@ public class AutogenConfig {
|
||||||
public int clientPort;
|
public int clientPort;
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
private boolean isInitModules;
|
private boolean isInitModules;
|
||||||
|
public boolean isUseBetterUpdate;
|
||||||
public String guardType;
|
public String guardType;
|
||||||
public String secretKeyClient;
|
public String secretKeyClient;
|
||||||
public String oemUnlockKey;
|
public String oemUnlockKey;
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
import pro.gravit.launcher.LauncherConfig;
|
||||||
import pro.gravit.launcher.hasher.HashedDir;
|
import pro.gravit.launcher.hasher.HashedDir;
|
||||||
import pro.gravit.launcher.hasher.HashedEntry;
|
import pro.gravit.launcher.hasher.HashedEntry;
|
||||||
import pro.gravit.utils.helper.IOHelper;
|
import pro.gravit.utils.helper.IOHelper;
|
||||||
|
@ -37,7 +38,7 @@ public static boolean needsZipUpdate(HashedDir origd, HashedDir entryd) {
|
||||||
if (!needsZip(orig)) return false;
|
if (!needsZip(orig)) return false;
|
||||||
double coffSize = BigDecimal.valueOf(entry.size).divide(BigDecimal.valueOf(orig.size)).doubleValue();
|
double coffSize = BigDecimal.valueOf(entry.size).divide(BigDecimal.valueOf(orig.size)).doubleValue();
|
||||||
double coffCnt = BigDecimal.valueOf(entry.cnt).divide(BigDecimal.valueOf(orig.cnt)).doubleValue();
|
double coffCnt = BigDecimal.valueOf(entry.cnt).divide(BigDecimal.valueOf(orig.cnt)).doubleValue();
|
||||||
return coffSize >= SIMPLE_DOWNLOAD_SIZE_COFF && SIMPLE_DOWNLOAD_FILE_COPF <= coffCnt;
|
return LauncherConfig.getAutogenConfig().isUseBetterUpdate && coffSize >= SIMPLE_DOWNLOAD_SIZE_COFF && SIMPLE_DOWNLOAD_FILE_COPF <= coffCnt;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Pair count(HashedDir hDir) {
|
private static Pair count(HashedDir hDir) {
|
||||||
|
|
Loading…
Reference in a new issue