Cache jarVersion and let it complain only once
This commit is contained in:
committed by
Sheepit Renderfarm
parent
ba1f865316
commit
27d992f485
@@ -623,7 +623,7 @@ import okhttp3.HttpUrl;
|
||||
|
||||
StringBuilder logHeader = new StringBuilder()
|
||||
.append("====================================================================================================\n")
|
||||
.append(String.format("%s / %s / %s / SheepIt v%s\n", conf.getLogin(), conf.getHostname(), OS.getOS().name(), conf.getJarVersion()))
|
||||
.append(String.format("%s / %s / %s / SheepIt v%s\n", conf.getLogin(), conf.getHostname(), OS.getOS().name(), Configuration.jarVersion))
|
||||
.append(String.format("%s x%d %.1f GB RAM\n", cpu.name(), conf.getNbCores(), conf.getMaxAllowedMemory() / 1024.0 / 1024.0));
|
||||
|
||||
if (conf.getComputeMethod() == Configuration.ComputeType.GPU || conf.getComputeMethod() == Configuration.ComputeType.CPU_GPU) {
|
||||
|
||||
@@ -40,6 +40,8 @@ import lombok.Data;
|
||||
@AllArgsConstructor
|
||||
@Data public class Configuration {
|
||||
|
||||
public static final String jarVersion = getJarVersion();
|
||||
|
||||
public enum ComputeType {
|
||||
CPU_GPU, CPU, GPU
|
||||
} // accept job for ...
|
||||
@@ -300,26 +302,24 @@ import lombok.Data;
|
||||
return files_local;
|
||||
}
|
||||
|
||||
public String getJarVersion() {
|
||||
private static String getJarVersion() {
|
||||
String versionPath = "/VERSION";
|
||||
String version = "6.0.0";
|
||||
|
||||
InputStream versionStream = Client.class.getResourceAsStream(versionPath);
|
||||
if (versionStream == null) {
|
||||
if (versionStream != null) {
|
||||
try {
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader(versionStream));
|
||||
version = in.readLine();
|
||||
}
|
||||
catch (IOException ex) {
|
||||
System.err.println("Configuration::getJarVersion error while reading manifest file (" + versionPath + "): " + ex.getMessage());
|
||||
}
|
||||
}
|
||||
else {
|
||||
System.err.println("Configuration::getJarVersion Failed to get version file");
|
||||
return "6.0.0";
|
||||
}
|
||||
|
||||
try {
|
||||
InputStreamReader reader = new InputStreamReader(versionStream);
|
||||
BufferedReader in = new BufferedReader(reader);
|
||||
String version = in.readLine();
|
||||
|
||||
return version;
|
||||
}
|
||||
catch (IOException ex) {
|
||||
System.err.println("Configuration::getJarVersion error while reading manifest file (" + versionPath + "): " + ex.getMessage());
|
||||
return "6.0.0";
|
||||
}
|
||||
return version;
|
||||
}
|
||||
|
||||
public boolean checkOSisSupported() {
|
||||
|
||||
@@ -208,7 +208,7 @@ public class Server extends Thread {
|
||||
.add("os_version", os.getVersion())
|
||||
.add("ram", String.valueOf(os.getTotalMemory()))
|
||||
.add("bits", os.getCPU().arch())
|
||||
.add("version", user_config.getJarVersion())
|
||||
.add("version", Configuration.jarVersion)
|
||||
.add("hostname", user_config.getHostname())
|
||||
.add("ui", client.getGui().getClass().getSimpleName())
|
||||
.add("extras", user_config.getExtras())
|
||||
|
||||
@@ -35,7 +35,7 @@ public class VersionParameterHandler<T> extends OptionHandler<T> {
|
||||
|
||||
@Override public int parseArguments(Parameters params) throws CmdLineException {
|
||||
Configuration config = new Configuration(null, "", "");
|
||||
System.out.println("Version: " + config.getJarVersion());
|
||||
System.out.println("Version: " + Configuration.jarVersion);
|
||||
System.exit(0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -431,7 +431,7 @@ public class Worker {
|
||||
settingsLoader.markLaunchSettings(List.of(args));
|
||||
}
|
||||
|
||||
Log.getInstance(config).debug("client version " + config.getJarVersion());
|
||||
Log.getInstance(config).debug("client version " + Configuration.jarVersion);
|
||||
|
||||
// Hostname change will overwrite the existing one (default or read from configuration file) but changes will be lost when the client closes
|
||||
if (hostname != null) {
|
||||
|
||||
@@ -141,7 +141,7 @@ public class Settings implements Activity {
|
||||
|
||||
Graphics gph = watermark.getGraphics();
|
||||
gph.setFont(gph.getFont().deriveFont(12f));
|
||||
gph.drawString("v" + config.getJarVersion(), 335, 120);
|
||||
gph.drawString("v" + Configuration.jarVersion, 335, 120);
|
||||
gph.dispose();
|
||||
|
||||
labelImage = new JLabel(new ImageIcon(watermark));
|
||||
|
||||
Reference in New Issue
Block a user