diff --git a/src/com/sheepit/client/Configuration.java b/src/com/sheepit/client/Configuration.java index f44c181..172d703 100644 --- a/src/com/sheepit/client/Configuration.java +++ b/src/com/sheepit/client/Configuration.java @@ -40,6 +40,7 @@ public class Configuration { CPU_GPU, CPU, GPU } // accept job for ... + private String configFilePath; public File workingDirectory; public File storageDirectory; // for permanent storage (binary archive) public boolean userHasSpecifiedACacheDir; @@ -64,6 +65,7 @@ public class Configuration { private String hostname; public Configuration(File cache_dir_, String login_, String password_) { + this.configFilePath = null; this.login = login_; this.password = password_; this.proxy = null; @@ -93,6 +95,14 @@ public class Configuration { public String toString() { return String.format("Configuration (workingDirectory '%s')", this.workingDirectory.getAbsolutePath()); } + + public String getConfigFilePath() { + return this.configFilePath; + } + + public void setConfigPath(String val) { + this.configFilePath = val; + } public String login() { return this.login; diff --git a/src/com/sheepit/client/SettingsLoader.java b/src/com/sheepit/client/SettingsLoader.java index 193a596..553bc87 100644 --- a/src/com/sheepit/client/SettingsLoader.java +++ b/src/com/sheepit/client/SettingsLoader.java @@ -55,16 +55,22 @@ public class SettingsLoader { private String tileSize; private int priority; - public SettingsLoader() { - path = getDefaultFilePath(); - } - public SettingsLoader(String path_) { - path = path_; + if (path_ == null) { + path = getDefaultFilePath(); + } + else { + path = path_; + } } - public SettingsLoader(String login_, String password_, String proxy_, String hostname_, ComputeType computeMethod_, GPUDevice gpu_, int cores_, int maxRam_, int maxRenderTime_, String cacheDir_, boolean autoSignIn_, String ui_, String tileSize_, int priority_) { - path = getDefaultFilePath(); + public SettingsLoader(String path_, String login_, String password_, String proxy_, String hostname_, ComputeType computeMethod_, GPUDevice gpu_, int cores_, int maxRam_, int maxRenderTime_, String cacheDir_, boolean autoSignIn_, String ui_, String tileSize_, int priority_) { + if (path_ == null) { + path = getDefaultFilePath(); + } + else { + path = path_; + } login = login_; password = password_; proxy = proxy_; diff --git a/src/com/sheepit/client/standalone/Worker.java b/src/com/sheepit/client/standalone/Worker.java index f003b3b..550f445 100644 --- a/src/com/sheepit/client/standalone/Worker.java +++ b/src/com/sheepit/client/standalone/Worker.java @@ -291,6 +291,7 @@ public class Worker { System.err.println("Aborting"); System.exit(2); } + config.setConfigPath(config_file); new SettingsLoader(config_file).merge(config); } diff --git a/src/com/sheepit/client/standalone/swing/activity/Settings.java b/src/com/sheepit/client/standalone/swing/activity/Settings.java index b016831..263fbb8 100644 --- a/src/com/sheepit/client/standalone/swing/activity/Settings.java +++ b/src/com/sheepit/client/standalone/swing/activity/Settings.java @@ -97,7 +97,7 @@ public class Settings implements Activity { @Override public void show() { Configuration config = parent.getConfiguration(); - new SettingsLoader().merge(config); + new SettingsLoader(config.getConfigFilePath()).merge(config); List gpus = GPU.listDevices(config); @@ -617,14 +617,7 @@ public class Settings implements Activity { } if (saveFile.isSelected()) { - new SettingsLoader(login.getText(), new String(password.getPassword()), proxyText, hostnameText, method, selected_gpu, cpu_cores, max_ram, max_rendertime, cachePath, autoSignIn.isSelected(), GuiSwing.type, tile, priority.getValue()).saveFile(); - } - else { - try { - new File(new SettingsLoader().getFilePath()).delete(); - } - catch (SecurityException e3) { - } + new SettingsLoader(config.getConfigFilePath(), login.getText(), new String(password.getPassword()), proxyText, hostnameText, method, selected_gpu, cpu_cores, max_ram, max_rendertime, cachePath, autoSignIn.isSelected(), GuiSwing.type, tile, priority.getValue()).saveFile(); } } }