Bugfix: merge the configuration and settings (Configuration i.e. command line args have high priority)

This commit is contained in:
Laurent Clouet
2015-03-31 23:06:21 +01:00
parent ad6547d3d9
commit 901fab65f2
2 changed files with 10 additions and 6 deletions

View File

@@ -58,7 +58,7 @@ public class Configuration {
this.static_exeDirName = "exe"; this.static_exeDirName = "exe";
this.maxUploadingJob = 1; this.maxUploadingJob = 1;
this.nbCores = -1; // ie not set this.nbCores = -1; // ie not set
this.computeMethod = ComputeType.CPU_ONLY; this.computeMethod = null;
this.GPUDevice = null; this.GPUDevice = null;
this.userSpecifiedACacheDir = false; this.userSpecifiedACacheDir = false;
this.workingDirectory = null; this.workingDirectory = null;

View File

@@ -144,6 +144,10 @@ public class SettingsLoader {
} }
} }
/**
* Merge the Settings file with the Configuration.
* The Configuration will have high priority.
*/
public void merge(Configuration config) { public void merge(Configuration config) {
if (config == null) { if (config == null) {
System.out.println("SettingsLoader::merge config is null"); System.out.println("SettingsLoader::merge config is null");
@@ -151,23 +155,23 @@ public class SettingsLoader {
loadFile(); loadFile();
if (login != null) { if (config.login().isEmpty() && login != null) {
config.setLogin(login); config.setLogin(login);
} }
if (password != null) { if (config.password().isEmpty() && password != null) {
config.setPassword(password); config.setPassword(password);
} }
if (computeMethod != null) { if (config.getComputeMethod() == null && computeMethod != null) {
config.setComputeMethod(ComputeType.valueOf(computeMethod)); config.setComputeMethod(ComputeType.valueOf(computeMethod));
} }
if (gpu != null) { if (config.getGPUDevice() == null && gpu != null) {
GPUDevice device = GPU.getGPUDevice(gpu); GPUDevice device = GPU.getGPUDevice(gpu);
if (device != null) { if (device != null) {
config.setUseGPU(device); config.setUseGPU(device);
} }
} }
if (cacheDir != null) { if (config.getUserSpecifiedACacheDir() == false && cacheDir != null) {
config.setCacheDir(new File(cacheDir)); config.setCacheDir(new File(cacheDir));
} }
} }