Feat: add an option for disabling large downloads
This commit is contained in:
@@ -63,7 +63,8 @@ public class SettingsLoader {
|
||||
USE_SYSTRAY("use-systray"),
|
||||
HEADLESS("headless"),
|
||||
UI("ui"),
|
||||
THEME("theme");
|
||||
THEME("theme"),
|
||||
DISABLE_LARGE_DOWNLOADS("disable-large-downloads");
|
||||
|
||||
String propertyName;
|
||||
|
||||
@@ -105,6 +106,7 @@ public class SettingsLoader {
|
||||
public static final String ARG_THEME = "-theme";
|
||||
public static final String ARG_HOSTNAME = "-hostname";
|
||||
public static final String ARG_HEADLESS = "--headless";
|
||||
public static final String ARG_DISABLE_LARGE_DOWNLOADS = "--disable-large-downloads";
|
||||
|
||||
|
||||
private String path;
|
||||
@@ -128,6 +130,7 @@ public class SettingsLoader {
|
||||
private Option<String> ui;
|
||||
private Option<String> theme;
|
||||
private Option<Integer> priority;
|
||||
private Option<String> disableLargeDownloads;
|
||||
|
||||
public SettingsLoader(String path_) {
|
||||
if (path_ == null) {
|
||||
@@ -141,7 +144,7 @@ public class SettingsLoader {
|
||||
public void setSettings(String path_, String login_, String password_, String proxy_, String hostname_,
|
||||
ComputeType computeMethod_, GPUDevice gpu_, Integer cores_, Long maxRam_,
|
||||
Integer maxRenderTime_, String cacheDir_, String sharedZip_, Boolean autoSignIn_, Boolean useSysTray_,
|
||||
Boolean isHeadless, String ui_, String theme_, Integer priority_) {
|
||||
Boolean isHeadless, String ui_, String theme_, Integer priority_, Boolean disableLargeDownloads_) {
|
||||
if (path_ == null) {
|
||||
path = OS.getOS().getDefaultConfigFilePath();
|
||||
}
|
||||
@@ -160,6 +163,8 @@ public class SettingsLoader {
|
||||
ui = setValue(ui_, ui, ARG_UI);
|
||||
priority = setValue(priority_, priority, ARG_PRIORITY);
|
||||
theme = setValue(theme_, theme, ARG_THEME);
|
||||
disableLargeDownloads = setValue(disableLargeDownloads_.toString(), disableLargeDownloads, ARG_DISABLE_LARGE_DOWNLOADS);
|
||||
|
||||
|
||||
if (cores_ > 0) {
|
||||
cores = setValue(cores_.toString(), cores, ARG_CORES);
|
||||
@@ -212,7 +217,7 @@ public class SettingsLoader {
|
||||
*/
|
||||
public void markLaunchSettings(List<String> argsList) {
|
||||
Option options[] = { login, password, proxy, hostname, computeMethod, gpu, cores, ram, renderTime, cacheDir, sharedZip,
|
||||
autoSignIn, useSysTray, headless, ui, theme, priority };
|
||||
autoSignIn, useSysTray, headless, ui, theme, priority, disableLargeDownloads };
|
||||
|
||||
for (Option option : options) {
|
||||
if (option != null && argsList.contains(option.getLaunchFlag())) {
|
||||
@@ -279,6 +284,7 @@ public class SettingsLoader {
|
||||
setProperty(prop, configFileProp, PropertyNames.HEADLESS, headless);
|
||||
setProperty(prop, configFileProp, PropertyNames.UI, ui);
|
||||
setProperty(prop, configFileProp, PropertyNames.THEME, theme);
|
||||
setProperty(prop, configFileProp, PropertyNames.DISABLE_LARGE_DOWNLOADS, disableLargeDownloads);
|
||||
prop.store(output, null);
|
||||
}
|
||||
catch (IOException io) {
|
||||
@@ -381,6 +387,8 @@ public class SettingsLoader {
|
||||
|
||||
theme = loadConfigOption(prop, PropertyNames.THEME, theme, ARG_THEME);
|
||||
|
||||
disableLargeDownloads = loadConfigOption(prop, PropertyNames.DISABLE_LARGE_DOWNLOADS, disableLargeDownloads, ARG_DISABLE_LARGE_DOWNLOADS);
|
||||
|
||||
if (prop.containsKey(PropertyNames.PRIORITY.propertyName)) {
|
||||
int prio = Integer.parseInt(prop.getProperty(PropertyNames.PRIORITY.propertyName));
|
||||
if (priority == null) {
|
||||
@@ -513,6 +521,10 @@ public class SettingsLoader {
|
||||
}
|
||||
}
|
||||
|
||||
if (config.isDisableLargeDownloads() == false && disableLargeDownloads != null) {
|
||||
config.setDisableLargeDownloads(Boolean.parseBoolean(disableLargeDownloads.getValue()));
|
||||
}
|
||||
|
||||
// if the user has invoked the app with --no-systray, then we just overwrite the existing configuration with (boolean)false. If no parameter has been
|
||||
// specified and the settings file contains use-systray=false, then deactivate as well.
|
||||
if (!config.isUseSysTray() || (config.isUseSysTray() && useSysTray != null && useSysTray.getValue().equals("false"))) {
|
||||
@@ -543,13 +555,12 @@ public class SettingsLoader {
|
||||
this.renderTime = null;
|
||||
this.theme = null;
|
||||
this.cores = new Option<>(String.valueOf(defaultConfigValues.getNbCores()), ARG_CORES);
|
||||
|
||||
|
||||
this.disableLargeDownloads = new Option<>(String.valueOf(defaultConfigValues.isDisableLargeDownloads()), ARG_DISABLE_LARGE_DOWNLOADS);
|
||||
}
|
||||
|
||||
@Override public String toString() {
|
||||
return String.format(
|
||||
"SettingsLoader [path=%s, login=%s, password=%s, computeMethod=%s, gpu=%s, cacheDir=%s, sharedZip=%s, theme=%s, priority=%d, autosign=%s, usetray=%s, headless=%s]",
|
||||
path, login, password, computeMethod, gpu, cacheDir, sharedZip, theme, priority, autoSignIn, useSysTray, headless);
|
||||
"SettingsLoader [path=%s, login=%s, password=%s, computeMethod=%s, gpu=%s, cacheDir=%s, sharedZip=%s, theme=%s, priority=%d, autosign=%s, usetray=%s, headless=%s, disableLargeDownloads=%s]",
|
||||
path, login, password, computeMethod, gpu, cacheDir, sharedZip, theme, priority, autoSignIn, useSysTray, headless, disableLargeDownloads);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user