review fixes
This commit is contained in:
@@ -1,9 +1,3 @@
|
|||||||
/*/target/
|
/*/target/
|
||||||
/target/
|
/target/
|
||||||
core/src/main/java/com/threerings/getdown/data/Build.java
|
core/src/main/java/com/threerings/getdown/data/Build.java
|
||||||
|
|
||||||
# IntelliJ IDEA
|
|
||||||
.idea/
|
|
||||||
*.iml
|
|
||||||
*.ipr
|
|
||||||
*.iws
|
|
||||||
|
|||||||
@@ -32,7 +32,8 @@ import static com.threerings.getdown.Log.log;
|
|||||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parses and provide access to the information contained in the {@code getdown.txt} configuration file.
|
* Parses and provide access to the information contained in the <code>getdown.txt</code>
|
||||||
|
* configuration file.
|
||||||
*/
|
*/
|
||||||
public class Application
|
public class Application
|
||||||
{
|
{
|
||||||
@@ -449,7 +450,9 @@ public class Application
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
String vmfile = _javaLocalDir.getName() + ".jar";
|
// take extension from java location
|
||||||
|
String vmfileExt = _javaLocation.substring(_javaLocation.lastIndexOf('.'));
|
||||||
|
String vmfile = _javaLocalDir.getName() + vmfileExt;
|
||||||
try {
|
try {
|
||||||
URL remote = new URL(createVAppBase(_targetVersion), encodePath(_javaLocation));
|
URL remote = new URL(createVAppBase(_targetVersion), encodePath(_javaLocation));
|
||||||
return new Resource(vmfile, remote, getLocalPath(vmfile),
|
return new Resource(vmfile, remote, getLocalPath(vmfile),
|
||||||
@@ -874,7 +877,7 @@ public class Application
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attempts to redownload the {@code getdown.txt} file based on information parsed from a
|
* Attempts to redownload the <code>getdown.txt</code> file based on information parsed from a
|
||||||
* previous call to {@link #init}.
|
* previous call to {@link #init}.
|
||||||
*/
|
*/
|
||||||
public void attemptRecovery (StatusDisplay status)
|
public void attemptRecovery (StatusDisplay status)
|
||||||
@@ -885,7 +888,7 @@ public class Application
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Downloads and replaces the {@code getdown.txt} and {@code digest.txt} files with
|
* Downloads and replaces the <code>getdown.txt</code> and <code>digest.txt</code> files with
|
||||||
* those for the target version of our application.
|
* those for the target version of our application.
|
||||||
*/
|
*/
|
||||||
public void updateMetadata ()
|
public void updateMetadata ()
|
||||||
@@ -932,7 +935,7 @@ public class Application
|
|||||||
public Process createProcess (boolean optimum)
|
public Process createProcess (boolean optimum)
|
||||||
throws IOException
|
throws IOException
|
||||||
{
|
{
|
||||||
List<String> args = new ArrayList<>();
|
ArrayList<String> args = new ArrayList<>();
|
||||||
|
|
||||||
// reconstruct the path to the JVM
|
// reconstruct the path to the JVM
|
||||||
args.add(LaunchUtil.getJVMBinaryPath(_javaLocalDir, _windebug || optimum));
|
args.add(LaunchUtil.getJVMBinaryPath(_javaLocalDir, _windebug || optimum));
|
||||||
@@ -1132,8 +1135,8 @@ public class Application
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads the {@code digest.txt} file and verifies the contents of both that file and the
|
* Loads the <code>digest.txt</code> file and verifies the contents of both that file and the
|
||||||
* {@code getdown.text} file. Then it loads the {@code version.txt} and decides
|
* <code>getdown.text</code> file. Then it loads the <code>version.txt</code> and decides
|
||||||
* whether or not the application needs to be updated or whether we can proceed to verification
|
* whether or not the application needs to be updated or whether we can proceed to verification
|
||||||
* and execution.
|
* and execution.
|
||||||
*
|
*
|
||||||
@@ -1552,6 +1555,7 @@ public class Application
|
|||||||
|
|
||||||
if (!sig.verify(Base64.decode(signature, Base64.DEFAULT))) {
|
if (!sig.verify(Base64.decode(signature, Base64.DEFAULT))) {
|
||||||
log.info("Signature does not match", "cert", cert.getPublicKey());
|
log.info("Signature does not match", "cert", cert.getPublicKey());
|
||||||
|
continue;
|
||||||
} else {
|
} else {
|
||||||
log.info("Signature matches", "cert", cert.getPublicKey());
|
log.info("Signature matches", "cert", cert.getPublicKey());
|
||||||
validated++;
|
validated++;
|
||||||
|
|||||||
@@ -237,7 +237,7 @@ public class Config
|
|||||||
*/
|
*/
|
||||||
public String getString (String name, String def) {
|
public String getString (String name, String def) {
|
||||||
String value = (String)_data.get(name);
|
String value = (String)_data.get(name);
|
||||||
return StringUtil.isBlank(value) ? def : value;
|
return value == null ? def : value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -17,19 +17,19 @@ import static com.threerings.getdown.Log.log;
|
|||||||
* Useful routines for launching Java applications from within other Java
|
* Useful routines for launching Java applications from within other Java
|
||||||
* applications.
|
* applications.
|
||||||
*/
|
*/
|
||||||
public final class LaunchUtil
|
public class LaunchUtil
|
||||||
{
|
{
|
||||||
/** The default directory into which a local VM installation should be unpacked. */
|
/** The default directory into which a local VM installation should be unpacked. */
|
||||||
public static final String LOCAL_JAVA_DIR = "java_vm";
|
public static final String LOCAL_JAVA_DIR = "java_vm";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Writes a {@code version.txt} file into the specified application directory and
|
* Writes a <code>version.txt</code> file into the specified application directory and
|
||||||
* attempts to relaunch Getdown in that directory which will cause it to upgrade to the newly
|
* attempts to relaunch Getdown in that directory which will cause it to upgrade to the newly
|
||||||
* specified version and relaunch the application.
|
* specified version and relaunch the application.
|
||||||
*
|
*
|
||||||
* @param appdir the directory in which the application is installed.
|
* @param appdir the directory in which the application is installed.
|
||||||
* @param getdownJarName the name of the getdown jar file in the application directory. This is
|
* @param getdownJarName the name of the getdown jar file in the application directory. This is
|
||||||
* probably {@code getdown-pro.jar} or <code>getdown-retro-pro.jar</code> if you are using
|
* probably <code>getdown-pro.jar</code> or <code>getdown-retro-pro.jar</code> if you are using
|
||||||
* the results of the standard build.
|
* the results of the standard build.
|
||||||
* @param newVersion the new version to which Getdown will update when it is executed.
|
* @param newVersion the new version to which Getdown will update when it is executed.
|
||||||
* @param javaLocalDir JRE location within appdir, falls back to {@link #LOCAL_JAVA_DIR} in case if null is passed
|
* @param javaLocalDir JRE location within appdir, falls back to {@link #LOCAL_JAVA_DIR} in case if null is passed
|
||||||
@@ -40,7 +40,7 @@ public final class LaunchUtil
|
|||||||
* after making this call as it will be upgraded and restarted. If false is returned, the
|
* after making this call as it will be upgraded and restarted. If false is returned, the
|
||||||
* application should tell the user that they must restart the application manually.
|
* application should tell the user that they must restart the application manually.
|
||||||
*
|
*
|
||||||
* @exception IOException thrown if we were unable to create the {@code version.txt} file
|
* @exception IOException thrown if we were unable to create the <code>version.txt</code> file
|
||||||
* in the supplied application directory. If the version.txt file cannot be created, restarting
|
* in the supplied application directory. If the version.txt file cannot be created, restarting
|
||||||
* Getdown will not cause the application to be upgraded, so the application will have to
|
* Getdown will not cause the application to be upgraded, so the application will have to
|
||||||
* resort to telling the user that it is in a bad way.
|
* resort to telling the user that it is in a bad way.
|
||||||
@@ -64,9 +64,7 @@ public final class LaunchUtil
|
|||||||
// do the deed
|
// do the deed
|
||||||
String[] args = {
|
String[] args = {
|
||||||
getJVMBinaryPath(new File(appdir, StringUtil.isBlank(javaLocalDir) ? LOCAL_JAVA_DIR : javaLocalDir), false),
|
getJVMBinaryPath(new File(appdir, StringUtil.isBlank(javaLocalDir) ? LOCAL_JAVA_DIR : javaLocalDir), false),
|
||||||
"-jar",
|
"-jar", pro.toString(), appdir.getPath()
|
||||||
pro.toString(),
|
|
||||||
appdir.getPath()
|
|
||||||
};
|
};
|
||||||
log.info("Running " + StringUtil.join(args, "\n "));
|
log.info("Running " + StringUtil.join(args, "\n "));
|
||||||
try {
|
try {
|
||||||
@@ -146,7 +144,8 @@ public final class LaunchUtil
|
|||||||
if (newgd.renameTo(curgd)) {
|
if (newgd.renameTo(curgd)) {
|
||||||
FileUtil.deleteHarder(oldgd); // yay!
|
FileUtil.deleteHarder(oldgd); // yay!
|
||||||
try {
|
try {
|
||||||
// copy the moved file back to newgd so that we don't end up downloading another copy next time
|
// copy the moved file back to newgd so that we don't end up
|
||||||
|
// downloading another copy next time
|
||||||
FileUtil.copy(curgd, newgd);
|
FileUtil.copy(curgd, newgd);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
log.warning("Error copying updated Getdown back: " + e);
|
log.warning("Error copying updated Getdown back: " + e);
|
||||||
@@ -177,23 +176,23 @@ public final class LaunchUtil
|
|||||||
public static boolean mustMonitorChildren ()
|
public static boolean mustMonitorChildren ()
|
||||||
{
|
{
|
||||||
String osname = System.getProperty("os.name", "").toLowerCase(Locale.ROOT);
|
String osname = System.getProperty("os.name", "").toLowerCase(Locale.ROOT);
|
||||||
return osname.contains("windows 98") || osname.contains("windows me");
|
return (osname.indexOf("windows 98") != -1 || osname.indexOf("windows me") != -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if we're running in a JVM that identifies its operating system as Windows.
|
* Returns true if we're running in a JVM that identifies its operating system as Windows.
|
||||||
*/
|
*/
|
||||||
public static boolean isWindows () { return _isWindows; }
|
public static final boolean isWindows () { return _isWindows; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if we're running in a JVM that identifies its operating system as MacOS.
|
* Returns true if we're running in a JVM that identifies its operating system as MacOS.
|
||||||
*/
|
*/
|
||||||
public static boolean isMacOS () { return _isMacOS; }
|
public static final boolean isMacOS () { return _isMacOS; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if we're running in a JVM that identifies its operating system as Linux.
|
* Returns true if we're running in a JVM that identifies its operating system as Linux.
|
||||||
*/
|
*/
|
||||||
public static boolean isLinux () { return _isLinux; }
|
public static final boolean isLinux () { return _isLinux; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks whether a Java Virtual Machine can be located in the supplied path.
|
* Checks whether a Java Virtual Machine can be located in the supplied path.
|
||||||
@@ -231,10 +230,11 @@ public final class LaunchUtil
|
|||||||
static {
|
static {
|
||||||
try {
|
try {
|
||||||
String osname = System.getProperty("os.name");
|
String osname = System.getProperty("os.name");
|
||||||
osname = osname == null ? "" : osname;
|
osname = (osname == null) ? "" : osname;
|
||||||
_isWindows = osname.contains("Windows");
|
_isWindows = (osname.indexOf("Windows") != -1);
|
||||||
_isMacOS = osname.contains("Mac OS") || osname.contains("MacOS");
|
_isMacOS = (osname.indexOf("Mac OS") != -1 ||
|
||||||
_isLinux = osname.contains("Linux");
|
osname.indexOf("MacOS") != -1);
|
||||||
|
_isLinux = (osname.indexOf("Linux") != -1);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// can't grab system properties; we'll just pretend we're not on any of these OSes
|
// can't grab system properties; we'll just pretend we're not on any of these OSes
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ public abstract class Getdown extends Thread
|
|||||||
// welcome to hell, where java can't cope with a classpath that contains jars that live
|
// welcome to hell, where java can't cope with a classpath that contains jars that live
|
||||||
// in a directory that contains a !, at least the same bug happens on all platforms
|
// in a directory that contains a !, at least the same bug happens on all platforms
|
||||||
String dir = envc.appDir.toString();
|
String dir = envc.appDir.toString();
|
||||||
if (".".equals(dir)) {
|
if (dir.equals(".")) {
|
||||||
dir = System.getProperty("user.dir");
|
dir = System.getProperty("user.dir");
|
||||||
}
|
}
|
||||||
String errmsg = "The directory in which this application is installed:\n" + dir +
|
String errmsg = "The directory in which this application is installed:\n" + dir +
|
||||||
@@ -130,7 +130,7 @@ public abstract class Getdown extends Thread
|
|||||||
File instdir = _app.getLocalPath("");
|
File instdir = _app.getLocalPath("");
|
||||||
if (!instdir.canWrite()) {
|
if (!instdir.canWrite()) {
|
||||||
String path = instdir.getPath();
|
String path = instdir.getPath();
|
||||||
if (".".equals(path)) {
|
if (path.equals(".")) {
|
||||||
path = System.getProperty("user.dir");
|
path = System.getProperty("user.dir");
|
||||||
}
|
}
|
||||||
fail(MessageUtil.tcompose("m.readonly_error", path));
|
fail(MessageUtil.tcompose("m.readonly_error", path));
|
||||||
@@ -824,7 +824,7 @@ public abstract class Getdown extends Thread
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update the status to indicate getdown has failed for the reason in {@code message}.
|
* Update the status to indicate getdown has failed for the reason in <code>message</code>.
|
||||||
*/
|
*/
|
||||||
protected void fail (String message)
|
protected void fail (String message)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user