Converted Getdown over to the new samskivert Logger. Added a patch from Elias

to recreate getdown.txt using the information provided to the applet if the
version on the filesystem is corrupt or references an old appbase.
This commit is contained in:
Michael Bayne
2008-10-23 21:00:12 +00:00
parent 6f9b70e970
commit 9a5e6ce17e
18 changed files with 225 additions and 204 deletions
+1 -26
View File
@@ -20,8 +20,7 @@
package com.threerings.getdown; package com.threerings.getdown;
import java.util.logging.Level; import com.samskivert.util.Logger;
import java.util.logging.Logger;
/** /**
* A placeholder class that contains a reference to the log object used by the Getdown code. * A placeholder class that contains a reference to the log object used by the Getdown code.
@@ -30,28 +29,4 @@ public class Log
{ {
/** We dispatch our log messages through this logger. */ /** We dispatch our log messages through this logger. */
public static Logger log = Logger.getLogger("com.threerings.getdown"); public static Logger log = Logger.getLogger("com.threerings.getdown");
/** Convenience function. */
public static void debug (String message)
{
log.fine(message);
}
/** Convenience function. */
public static void info (String message)
{
log.info(message);
}
/** Convenience function. */
public static void warning (String message)
{
log.warning(message);
}
/** Convenience function. */
public static void logStackTrace (Throwable t)
{
log.log(Level.WARNING, t.getMessage(), t);
}
} }
@@ -64,7 +64,7 @@ import com.samskivert.text.MessageUtil;
import com.samskivert.util.ArrayIntSet; import com.samskivert.util.ArrayIntSet;
import com.samskivert.util.RunAnywhere; import com.samskivert.util.RunAnywhere;
import com.samskivert.util.StringUtil; import com.samskivert.util.StringUtil;
import com.threerings.getdown.Log;
import com.threerings.getdown.launcher.RotatingBackgrounds; import com.threerings.getdown.launcher.RotatingBackgrounds;
import com.threerings.getdown.util.ConfigUtil; import com.threerings.getdown.util.ConfigUtil;
import com.threerings.getdown.util.FileUtil; import com.threerings.getdown.util.FileUtil;
@@ -72,6 +72,8 @@ import com.threerings.getdown.util.LaunchUtil;
import com.threerings.getdown.util.MetaProgressObserver; import com.threerings.getdown.util.MetaProgressObserver;
import com.threerings.getdown.util.ProgressObserver; import com.threerings.getdown.util.ProgressObserver;
import static com.threerings.getdown.Log.log;
/** /**
* Parses and provide access to the information contained in the <code>getdown.txt</code> * Parses and provide access to the information contained in the <code>getdown.txt</code>
* configuration file. * configuration file.
@@ -293,7 +295,7 @@ public class Application
public Resource getPatchResource (String auxgroup) public Resource getPatchResource (String auxgroup)
{ {
if (_targetVersion <= _version) { if (_targetVersion <= _version) {
Log.warning("Requested patch resource for up-to-date or non-versioned application " + log.warning("Requested patch resource for up-to-date or non-versioned application " +
"[cvers=" + _version + ", tvers=" + _targetVersion + "]."); "[cvers=" + _version + ", tvers=" + _targetVersion + "].");
return null; return null;
} }
@@ -304,7 +306,7 @@ public class Application
URL remote = new URL(createVAppBase(_targetVersion), pfile); URL remote = new URL(createVAppBase(_targetVersion), pfile);
return new Resource(pfile, remote, getLocalPath(pfile), false); return new Resource(pfile, remote, getLocalPath(pfile), false);
} catch (Exception e) { } catch (Exception e) {
Log.warning("Failed to create patch resource path [pfile=" + pfile + log.warning("Failed to create patch resource path [pfile=" + pfile +
", appbase=" + _appbase + ", tvers=" + _targetVersion + ", appbase=" + _appbase + ", tvers=" + _targetVersion +
", error=" + e + "]."); ", error=" + e + "].");
return null; return null;
@@ -327,7 +329,7 @@ public class Application
URL remote = new URL(createVAppBase(_targetVersion), _javaLocation); URL remote = new URL(createVAppBase(_targetVersion), _javaLocation);
return new Resource(vmfile, remote, getLocalPath(vmfile), true); return new Resource(vmfile, remote, getLocalPath(vmfile), true);
} catch (Exception e) { } catch (Exception e) {
Log.warning("Failed to create VM resource [vmfile=" + vmfile + ", appbase=" + _appbase + log.warning("Failed to create VM resource [vmfile=" + vmfile + ", appbase=" + _appbase +
", tvers=" + _targetVersion + ", javaloc=" + _javaLocation + ", tvers=" + _targetVersion + ", javaloc=" + _javaLocation +
", error=" + e + "]."); ", error=" + e + "].");
return null; return null;
@@ -345,7 +347,7 @@ public class Application
URL remote = new URL(createVAppBase(_targetVersion), file); URL remote = new URL(createVAppBase(_targetVersion), file);
return new Resource(file, remote, getLocalPath(file), false); return new Resource(file, remote, getLocalPath(file), false);
} catch (Exception e) { } catch (Exception e) {
Log.warning("Failed to create full resource path [file=" + file + log.warning("Failed to create full resource path [file=" + file +
", appbase=" + _appbase + ", tvers=" + _targetVersion + ", appbase=" + _appbase + ", tvers=" + _targetVersion +
", error=" + e + "]."); ", error=" + e + "].");
return null; return null;
@@ -364,7 +366,7 @@ public class Application
String suffix = _trackingURLSuffix == null ? "" : _trackingURLSuffix; String suffix = _trackingURLSuffix == null ? "" : _trackingURLSuffix;
return _trackingURL == null ? null : new URL(_trackingURL + event + suffix); return _trackingURL == null ? null : new URL(_trackingURL + event + suffix);
} catch (MalformedURLException mue) { } catch (MalformedURLException mue) {
Log.warning("Invalid tracking URL [path=" + _trackingURL + ", event=" + event + log.warning("Invalid tracking URL [path=" + _trackingURL + ", event=" + event +
", error=" + mue + "]."); ", error=" + mue + "].");
return null; return null;
} }
@@ -565,7 +567,7 @@ public class Application
_jvmargs.add(pair[0] + "=" + pair[1]); _jvmargs.add(pair[0] + "=" + pair[1]);
} }
} catch (Throwable t) { } catch (Throwable t) {
Log.warning("Failed to parse '" + file + "': " + t); log.warning("Failed to parse '" + file + "': " + t);
} }
} }
@@ -650,7 +652,7 @@ public class Application
if (!m.matches()) { if (!m.matches()) {
// if we can't parse the java version we're in weird land and should probably just try // if we can't parse the java version we're in weird land and should probably just try
// our luck with what we've got rather than try to download a new jvm // our luck with what we've got rather than try to download a new jvm
Log.warning("Unable to parse VM version, hoping for the best [version=" + verstr + log.warning("Unable to parse VM version, hoping for the best [version=" + verstr +
", needed=" + _javaVersion + "]."); ", needed=" + _javaVersion + "].");
return true; return true;
} }
@@ -759,7 +761,7 @@ public class Application
String[] sargs = new String[args.size()]; String[] sargs = new String[args.size()];
args.toArray(sargs); args.toArray(sargs);
Log.info("Running " + StringUtil.join(sargs, "\n ")); log.info("Running " + StringUtil.join(sargs, "\n "));
return Runtime.getRuntime().exec(sargs, null); return Runtime.getRuntime().exec(sargs, null);
} }
@@ -793,7 +795,7 @@ public class Application
jvmarg = processArg(jvmarg.substring(2)); jvmarg = processArg(jvmarg.substring(2));
int eqidx = jvmarg.indexOf("="); int eqidx = jvmarg.indexOf("=");
if (eqidx == -1) { if (eqidx == -1) {
Log.warning("Bogus system property: '" + jvmarg + "'?"); log.warning("Bogus system property: '" + jvmarg + "'?");
} else { } else {
System.setProperty(jvmarg.substring(0, eqidx), jvmarg.substring(eqidx+1)); System.setProperty(jvmarg.substring(0, eqidx), jvmarg.substring(eqidx+1));
} }
@@ -857,21 +859,21 @@ public class Application
public boolean verifyMetadata (StatusDisplay status) public boolean verifyMetadata (StatusDisplay status)
throws IOException throws IOException
{ {
Log.info("Verifying application: " + _vappbase); log.info("Verifying application: " + _vappbase);
Log.info("Version: " + _version); log.info("Version: " + _version);
Log.info("Class: " + _class); log.info("Class: " + _class);
// Log.info("Code: " + // log.info("Code: " +
// StringUtil.toString(getCodeResources().iterator())); // StringUtil.toString(getCodeResources().iterator()));
// Log.info("Resources: " + // log.info("Resources: " +
// StringUtil.toString(getActiveResources().iterator())); // StringUtil.toString(getActiveResources().iterator()));
// Log.info("JVM Args: " + StringUtil.toString(_jvmargs.iterator())); // log.info("JVM Args: " + StringUtil.toString(_jvmargs.iterator()));
// Log.info("App Args: " + StringUtil.toString(_appargs.iterator())); // log.info("App Args: " + StringUtil.toString(_appargs.iterator()));
// this will read in the contents of the digest file and validate itself // this will read in the contents of the digest file and validate itself
try { try {
_digest = new Digest(_appdir); _digest = new Digest(_appdir);
} catch (IOException ioe) { } catch (IOException ioe) {
Log.info("Failed to load digest: " + ioe.getMessage() + ". Attempting recovery..."); log.info("Failed to load digest: " + ioe.getMessage() + ". Attempting recovery...");
} }
// if we have no version, then we are running in unversioned mode so we need to download // if we have no version, then we are running in unversioned mode so we need to download
@@ -885,12 +887,12 @@ public class Application
downloadDigestFile(); downloadDigestFile();
_digest = new Digest(_appdir); _digest = new Digest(_appdir);
if (!olddig.equals(_digest.getMetaDigest())) { if (!olddig.equals(_digest.getMetaDigest())) {
Log.info("Unversioned digest changed. Revalidating..."); log.info("Unversioned digest changed. Revalidating...");
status.updateStatus("m.validating"); status.updateStatus("m.validating");
clearValidationMarkers(); clearValidationMarkers();
} }
} catch (IOException ioe) { } catch (IOException ioe) {
Log.warning("Failed to refresh non-versioned digest: " + log.warning("Failed to refresh non-versioned digest: " +
ioe.getMessage() + ". Proceeding..."); ioe.getMessage() + ". Proceeding...");
} }
} }
@@ -919,7 +921,7 @@ public class Application
if (_digest.validateResource(crsrc, null)) { if (_digest.validateResource(crsrc, null)) {
init(true); init(true);
} else { } else {
Log.warning(CONFIG_FILE + " failed to validate even after redownloading. " + log.warning(CONFIG_FILE + " failed to validate even after redownloading. " +
"Blindly forging onward."); "Blindly forging onward.");
} }
} }
@@ -939,7 +941,7 @@ public class Application
_targetVersion = Long.parseLong(vstr); _targetVersion = Long.parseLong(vstr);
} }
} catch (Exception e) { } catch (Exception e) {
Log.info("Unable to read version file: " + e.getMessage()); log.info("Unable to read version file: " + e.getMessage());
} finally { } finally {
StreamUtil.close(fin); StreamUtil.close(fin);
} }
@@ -992,11 +994,11 @@ public class Application
rsrc.markAsValid(); rsrc.markAsValid();
continue; continue;
} }
Log.info("Failure unpacking resource [rsrc=" + rsrc + "]."); log.info("Failure unpacking resource [rsrc=" + rsrc + "].");
} }
} catch (Exception e) { } catch (Exception e) {
Log.info("Failure validating resource [rsrc=" + rsrc + ", error=" + e + "]. " + log.info("Failure validating resource [rsrc=" + rsrc + ", error=" + e + "]. " +
"Requesting redownload..."); "Requesting redownload...");
} finally { } finally {
@@ -1056,22 +1058,19 @@ public class Application
try { try {
_lockChannel = new RandomAccessFile(getLocalPath("gettingdown.lock"), "rw").getChannel(); _lockChannel = new RandomAccessFile(getLocalPath("gettingdown.lock"), "rw").getChannel();
} catch (FileNotFoundException e) { } catch (FileNotFoundException e) {
Log.warning("Unable to create lock file [message=" + e.getMessage() + "]"); log.warning("Unable to create lock file [message=" + e.getMessage() + "]", e);
Log.logStackTrace(e);
return false; return false;
} }
try { try {
_lock = _lockChannel.tryLock(); _lock = _lockChannel.tryLock();
} catch (IOException e) { } catch (IOException e) {
Log.warning("Unable to create lock [message=" + e.getMessage() + "]"); log.warning("Unable to create lock [message=" + e.getMessage() + "]", e);
Log.logStackTrace(e);
return false; return false;
} catch (OverlappingFileLockException e) { } catch (OverlappingFileLockException e) {
Log.warning("The lock is held elsewhere in this JVM"); log.warning("The lock is held elsewhere in this JVM", e);
Log.logStackTrace(e);
return false; return false;
} }
Log.info("Able to lock for updates: " + (_lock != null)); log.info("Able to lock for updates: " + (_lock != null));
return _lock != null; return _lock != null;
} }
@@ -1081,18 +1080,16 @@ public class Application
public synchronized void releaseLock () public synchronized void releaseLock ()
{ {
if (_lock != null) { if (_lock != null) {
Log.info("Releasing lock"); log.info("Releasing lock");
try { try {
_lock.release(); _lock.release();
} catch (IOException e) { } catch (IOException e) {
Log.warning("Unable to release lock [message=" + e.getMessage() + "]"); log.warning("Unable to release lock [message=" + e.getMessage() + "]", e);
Log.logStackTrace(e);
} }
try { try {
_lockChannel.close(); _lockChannel.close();
} catch (IOException e) { } catch (IOException e) {
Log.warning("Unable to close lock channel [message=" + e.getMessage() + "]"); log.warning("Unable to close lock channel [message=" + e.getMessage() + "]", e);
Log.logStackTrace(e);
} }
_lockChannel = null; _lockChannel = null;
_lock = null; _lock = null;
@@ -1128,7 +1125,7 @@ public class Application
if (validateSignature) { if (validateSignature) {
if (_signers == null) { if (_signers == null) {
Log.info("No signers, not verifying file [path=" + path + "]."); log.info("No signers, not verifying file [path=" + path + "].");
} else { } else {
File signatureFile = downloadFile(path + SIGNATURE_SUFFIX); File signatureFile = downloadFile(path + SIGNATURE_SUFFIX);
@@ -1160,15 +1157,15 @@ public class Application
} }
if (!sig.verify(Base64.decodeBase64(signature))) { if (!sig.verify(Base64.decodeBase64(signature))) {
Log.info("Signature does not match [cert=" + cert.getPublicKey() + "]"); log.info("Signature does not match [cert=" + cert.getPublicKey() + "]");
continue; continue;
} else { } else {
Log.info("Signature matches [cert=" + cert.getPublicKey() + "]"); log.info("Signature matches [cert=" + cert.getPublicKey() + "]");
validated++; validated++;
} }
} catch (IOException ioe) { } catch (IOException ioe) {
Log.warning("Failure validating signature of " + target + ": " + ioe); log.warning("Failure validating signature of " + target + ": " + ioe);
} catch (GeneralSecurityException gse) { } catch (GeneralSecurityException gse) {
// no problem! // no problem!
@@ -1208,12 +1205,12 @@ public class Application
try { try {
targetURL = getRemoteURL(path); targetURL = getRemoteURL(path);
} catch (Exception e) { } catch (Exception e) {
Log.warning("Requested to download invalid control file [appbase=" + _vappbase + log.warning("Requested to download invalid control file [appbase=" + _vappbase +
", path=" + path + ", error=" + e + "]."); ", path=" + path + ", error=" + e + "].");
throw (IOException) new IOException("Invalid path '" + path + "'.").initCause(e); throw (IOException) new IOException("Invalid path '" + path + "'.").initCause(e);
} }
Log.info("Attempting to refetch '" + path + "' from '" + targetURL + "'."); log.info("Attempting to refetch '" + path + "' from '" + targetURL + "'.");
// stream the URL into our temporary file // stream the URL into our temporary file
InputStream fin = null; InputStream fin = null;
@@ -1249,7 +1246,7 @@ public class Application
try { try {
list.add(createResource(rsrc, unpack)); list.add(createResource(rsrc, unpack));
} catch (Exception e) { } catch (Exception e) {
Log.warning("Invalid resource '" + rsrc + "'. " + e); log.warning("Invalid resource '" + rsrc + "'. " + e);
} }
} }
} }
@@ -1263,7 +1260,7 @@ public class Application
if (v != null && v.length == 4) { if (v != null && v.length == 4) {
return new Rectangle(v[0], v[1], v[2], v[3]); return new Rectangle(v[0], v[1], v[2], v[3]);
} else { } else {
Log.warning("Ignoring invalid '" + name + "' config '" + value + "'."); log.warning("Ignoring invalid '" + name + "' config '" + value + "'.");
} }
} }
return def; return def;
@@ -1277,7 +1274,7 @@ public class Application
try { try {
return new Color(Integer.parseInt(value, 16)); return new Color(Integer.parseInt(value, 16));
} catch (Exception e) { } catch (Exception e) {
Log.warning("Ignoring invalid '" + name + "' config '" + value + "'."); log.warning("Ignoring invalid '" + name + "' config '" + value + "'.");
} }
} }
return def; return def;
@@ -36,10 +36,11 @@ import java.util.List;
import com.samskivert.text.MessageUtil; import com.samskivert.text.MessageUtil;
import com.samskivert.util.StringUtil; import com.samskivert.util.StringUtil;
import com.threerings.getdown.Log;
import com.threerings.getdown.util.ConfigUtil; import com.threerings.getdown.util.ConfigUtil;
import com.threerings.getdown.util.ProgressObserver; import com.threerings.getdown.util.ProgressObserver;
import static com.threerings.getdown.Log.log;
/** /**
* Manages the <code>digest.txt</code> file and the computing and * Manages the <code>digest.txt</code> file and the computing and
* processing of MD5 digests for an application. * processing of MD5 digests for an application.
@@ -106,10 +107,10 @@ public class Digest
if (cmd5.equals(emd5)) { if (cmd5.equals(emd5)) {
return true; return true;
} }
Log.info("Resource failed digest check [rsrc=" + resource + log.info("Resource failed digest check [rsrc=" + resource +
", computed=" + cmd5 + ", expected=" + emd5 + "]."); ", computed=" + cmd5 + ", expected=" + emd5 + "].");
} catch (Throwable t) { } catch (Throwable t) {
Log.info("Resource failed digest check [rsrc=" + resource + log.info("Resource failed digest check [rsrc=" + resource +
", error=" + t + "]."); ", error=" + t + "].");
} }
return false; return false;
@@ -39,9 +39,10 @@ import com.samskivert.util.FileUtil;
import com.samskivert.util.SortableArrayList; import com.samskivert.util.SortableArrayList;
import com.samskivert.util.StringUtil; import com.samskivert.util.StringUtil;
import com.threerings.getdown.Log;
import com.threerings.getdown.util.ProgressObserver; import com.threerings.getdown.util.ProgressObserver;
import static com.threerings.getdown.Log.log;
/** /**
* Models a single file resource used by an {@link Application}. * Models a single file resource used by an {@link Application}.
*/ */
@@ -135,7 +136,7 @@ public class Resource
{ {
if (_marker.exists()) { if (_marker.exists()) {
if (!_marker.delete()) { if (!_marker.delete()) {
Log.warning("Failed to erase marker file '" + _marker + "'."); log.warning("Failed to erase marker file '" + _marker + "'.");
} }
} }
} }
@@ -148,13 +149,13 @@ public class Resource
{ {
// sanity check // sanity check
if (!_local.getPath().endsWith(".jar")) { if (!_local.getPath().endsWith(".jar")) {
Log.warning("Requested to unpack non-jar file '" + _local + "'."); log.warning("Requested to unpack non-jar file '" + _local + "'.");
return false; return false;
} }
try { try {
return FileUtil.unpackJar(new JarFile(_local), _local.getParentFile()); return FileUtil.unpackJar(new JarFile(_local), _local.getParentFile());
} catch (IOException ioe) { } catch (IOException ioe) {
Log.warning("Failed to create JarFile from '" + _local + "': " + ioe); log.warning("Failed to create JarFile from '" + _local + "': " + ioe);
return false; return false;
} }
} }
@@ -168,7 +169,7 @@ public class Resource
clearMarker(); clearMarker();
if (_local.exists()) { if (_local.exists()) {
if (!_local.delete()) { if (!_local.delete()) {
Log.warning("Failed to erase resource '" + _local + "'."); log.warning("Failed to erase resource '" + _local + "'.");
} }
} }
} }
@@ -250,8 +251,7 @@ public class Resource
try { try {
jar.close(); jar.close();
} catch (IOException ioe) { } catch (IOException ioe) {
Log.warning("Error closing jar [path=" + target + log.warning("Error closing jar [path=" + target + ", error=" + ioe + "].");
", error=" + ioe + "].");
} }
} }
@@ -38,7 +38,7 @@ import com.samskivert.swing.Spacer;
import com.samskivert.swing.VGroupLayout; import com.samskivert.swing.VGroupLayout;
import com.samskivert.text.MessageUtil; import com.samskivert.text.MessageUtil;
import com.threerings.getdown.Log; import static com.threerings.getdown.Log.log;
/** /**
* Displays a confirmation that the user wants to abort installation. * Displays a confirmation that the user wants to abort installation.
@@ -104,7 +104,7 @@ public class AbortPanel extends JFrame
try { try {
return _msgs.getString(key); return _msgs.getString(key);
} catch (MissingResourceException mre) { } catch (MissingResourceException mre) {
Log.warning("Missing translation message '" + key + "'."); log.warning("Missing translation message '" + key + "'.");
return key; return key;
} }
} }
@@ -59,7 +59,6 @@ import com.samskivert.text.MessageUtil;
import com.samskivert.util.RunAnywhere; import com.samskivert.util.RunAnywhere;
import com.samskivert.util.StringUtil; import com.samskivert.util.StringUtil;
import com.threerings.getdown.Log;
import com.threerings.getdown.data.Application; import com.threerings.getdown.data.Application;
import com.threerings.getdown.data.Resource; import com.threerings.getdown.data.Resource;
import com.threerings.getdown.net.Downloader; import com.threerings.getdown.net.Downloader;
@@ -70,6 +69,8 @@ import com.threerings.getdown.util.ConfigUtil;
import com.threerings.getdown.util.LaunchUtil; import com.threerings.getdown.util.LaunchUtil;
import com.threerings.getdown.util.ProgressObserver; import com.threerings.getdown.util.ProgressObserver;
import static com.threerings.getdown.Log.log;
/** /**
* Manages the main control for the Getdown application updater and deployment system. * Manages the main control for the Getdown application updater and deployment system.
*/ */
@@ -130,7 +131,7 @@ public abstract class Getdown extends Thread
_ifc = _app.init(true); _ifc = _app.init(true);
createInterface(true); createInterface(true);
} catch (Exception e) { } catch (Exception e) {
Log.warning("Failed to preinit: " + e); log.warning("Failed to preinit: " + e);
createInterface(true); createInterface(true);
} }
} }
@@ -159,7 +160,7 @@ public abstract class Getdown extends Thread
if (detectProxy()) { if (detectProxy()) {
getdown(); getdown();
} else if (_silent) { } else if (_silent) {
Log.warning("Need a proxy, but we don't want to bother anyone. Exiting"); log.warning("Need a proxy, but we don't want to bother anyone. Exiting.");
} else { } else {
// create a panel they can use to configure the proxy settings // create a panel they can use to configure the proxy settings
_container = createContainer(); _container = createContainer();
@@ -170,7 +171,7 @@ public abstract class Getdown extends Thread
} }
} catch (Exception e) { } catch (Exception e) {
Log.logStackTrace(e); log.warning("run() failed.", e);
String msg = e.getMessage(); String msg = e.getMessage();
if (msg == null) { if (msg == null) {
msg = MessageUtil.compose("m.unknown_error", _ifc.installError); msg = MessageUtil.compose("m.unknown_error", _ifc.installError);
@@ -193,7 +194,7 @@ public abstract class Getdown extends Thread
*/ */
public void configureProxy (String host, String port) public void configureProxy (String host, String port)
{ {
Log.info("User configured proxy [host=" + host + ", port=" + port + "]."); log.info("User configured proxy [host=" + host + ", port=" + port + "].");
// if we're provided with valid values, create a proxy.txt file // if we're provided with valid values, create a proxy.txt file
if (!StringUtil.isBlank(host)) { if (!StringUtil.isBlank(host)) {
@@ -206,7 +207,7 @@ public abstract class Getdown extends Thread
} }
pout.close(); pout.close();
} catch (IOException ioe) { } catch (IOException ioe) {
Log.warning("Error creating proxy file '" + pfile + "': " + ioe); log.warning("Error creating proxy file '" + pfile + "': " + ioe);
} }
// also configure them in the JVM // also configure them in the JVM
@@ -261,11 +262,11 @@ public abstract class Getdown extends Thread
setProxyProperties(host, port); setProxyProperties(host, port);
return true; return true;
} else { } else {
Log.info("Detected no proxy settings in the registry."); log.info("Detected no proxy settings in the registry.");
} }
} catch (Throwable t) { } catch (Throwable t) {
Log.info("Failed to find proxy settings in Windows registry [error=" + t + "]."); log.info("Failed to find proxy settings in Windows registry [error=" + t + "].");
} }
} }
@@ -277,13 +278,13 @@ public abstract class Getdown extends Thread
setProxyProperties((String)pconf.get("host"), (String)pconf.get("port")); setProxyProperties((String)pconf.get("host"), (String)pconf.get("port"));
return true; return true;
} catch (IOException ioe) { } catch (IOException ioe) {
Log.warning("Failed to read '" + pfile + "': " + ioe); log.warning("Failed to read '" + pfile + "': " + ioe);
} }
} }
// otherwise see if we actually need a proxy; first we have to initialize our application // otherwise see if we actually need a proxy; first we have to initialize our application
// to get some sort of interface configuration and the appbase URL // to get some sort of interface configuration and the appbase URL
Log.info("Checking whether we need to use a proxy..."); log.info("Checking whether we need to use a proxy...");
try { try {
_ifc = _app.init(true); _ifc = _app.init(true);
} catch (IOException ioe) { } catch (IOException ioe) {
@@ -300,23 +301,23 @@ public abstract class Getdown extends Thread
// make sure we got a satisfactory response code // make sure we got a satisfactory response code
if (ucon.getResponseCode() != HttpURLConnection.HTTP_OK) { if (ucon.getResponseCode() != HttpURLConnection.HTTP_OK) {
Log.warning("Got a non-200 response but assuming we're OK because we got " + log.warning("Got a non-200 response but assuming we're OK because we got " +
"something... [url=" + rurl + ", rsp=" + ucon.getResponseCode() + "]."); "something... [url=" + rurl + ", rsp=" + ucon.getResponseCode() + "].");
} }
// we got through, so we appear not to require a proxy; make a blank proxy config and // we got through, so we appear not to require a proxy; make a blank proxy config and
// get on gettin' down // get on gettin' down
Log.info("No proxy appears to be needed."); log.info("No proxy appears to be needed.");
try { try {
pfile.createNewFile(); pfile.createNewFile();
} catch (IOException ioe) { } catch (IOException ioe) {
Log.warning("Failed to create blank proxy file '" + pfile + "': " + ioe); log.warning("Failed to create blank proxy file '" + pfile + "': " + ioe);
} }
return true; return true;
} catch (IOException ioe) { } catch (IOException ioe) {
Log.info("Failed to HEAD " + rurl + ": " + ioe); log.info("Failed to HEAD " + rurl + ": " + ioe);
Log.info("We probably need a proxy, but auto-detection failed."); log.info("We probably need a proxy, but auto-detection failed.");
} }
// let the caller know that we need a proxy but can't detect it // let the caller know that we need a proxy but can't detect it
@@ -333,7 +334,7 @@ public abstract class Getdown extends Thread
if (!StringUtil.isBlank(port)) { if (!StringUtil.isBlank(port)) {
System.setProperty("http.proxyPort", port); System.setProperty("http.proxyPort", port);
} }
Log.info("Using proxy [host=" + host + ", port=" + port + "]."); log.info("Using proxy [host=" + host + ", port=" + port + "].");
} }
} }
@@ -342,17 +343,17 @@ public abstract class Getdown extends Thread
*/ */
protected void getdown () protected void getdown ()
{ {
Log.info("---------------- Proxy Info -----------------"); log.info("---------------- Proxy Info -----------------");
Log.info("-- Proxy Host: " + System.getProperty("http.proxyHost")); log.info("-- Proxy Host: " + System.getProperty("http.proxyHost"));
Log.info("-- Proxy Port: " + System.getProperty("http.proxyPort")); log.info("-- Proxy Port: " + System.getProperty("http.proxyPort"));
Log.info("---------------------------------------------"); log.info("---------------------------------------------");
try { try {
// first parses our application deployment file // first parses our application deployment file
try { try {
_ifc = _app.init(true); _ifc = _app.init(true);
} catch (IOException ioe) { } catch (IOException ioe) {
Log.warning("Failed to parse 'getdown.txt': " + ioe); log.warning("Failed to parse 'getdown.txt': " + ioe);
_app.attemptRecovery(this); _app.attemptRecovery(this);
// and re-initalize // and re-initalize
_ifc = _app.init(true); _ifc = _app.init(true);
@@ -366,18 +367,18 @@ public abstract class Getdown extends Thread
// Update the config modtime so a sleeping getdown will notice the change. // Update the config modtime so a sleeping getdown will notice the change.
File config = _app.getLocalPath(Application.CONFIG_FILE); File config = _app.getLocalPath(Application.CONFIG_FILE);
if (!config.setLastModified(System.currentTimeMillis())) { if (!config.setLastModified(System.currentTimeMillis())) {
Log.warning("Unable to set modtime on config file, will be unable to check for " log.warning("Unable to set modtime on config file, will be unable to check for " +
+ "another instance of getdown running while this one waits."); "another instance of getdown running while this one waits.");
} }
if (_delay > 0) { if (_delay > 0) {
// don't hold the lock while waiting, let another getdown proceed if it starts. // don't hold the lock while waiting, let another getdown proceed if it starts.
_app.releaseLock(); _app.releaseLock();
// Store the config modtime before waiting the delay amount of time // Store the config modtime before waiting the delay amount of time
long lastConfigModtime = config.lastModified(); long lastConfigModtime = config.lastModified();
Log.info("Waiting " + _delay + " minutes before beginning actual work"); log.info("Waiting " + _delay + " minutes before beginning actual work.");
Thread.sleep(_delay * 60 * 1000); Thread.sleep(_delay * 60 * 1000);
if (lastConfigModtime < config.lastModified()) { if (lastConfigModtime < config.lastModified()) {
Log.warning("getdown.txt was modified while getdown was waiting"); log.warning("getdown.txt was modified while getdown was waiting.");
throw new MultipleGetdownRunning(); throw new MultipleGetdownRunning();
} }
} }
@@ -396,7 +397,7 @@ public abstract class Getdown extends Thread
if (!_app.haveValidJavaVersion()) { if (!_app.haveValidJavaVersion()) {
// download and install the necessary version of java, then loop back again and // download and install the necessary version of java, then loop back again and
// reverify everything; if we can't download java; we'll throw an exception // reverify everything; if we can't download java; we'll throw an exception
Log.info("Attempting to update Java VM..."); log.info("Attempting to update Java VM...");
_enableTracking = true; // always track JVM downloads _enableTracking = true; // always track JVM downloads
try { try {
updateJava(); updateJava();
@@ -409,7 +410,7 @@ public abstract class Getdown extends Thread
// make sure we have the desired version and that the metadata files are valid... // make sure we have the desired version and that the metadata files are valid...
setStatus("m.validating", -1, -1L, false); setStatus("m.validating", -1, -1L, false);
if (_app.verifyMetadata(this)) { if (_app.verifyMetadata(this)) {
Log.info("Application requires update."); log.info("Application requires update.");
update(); update();
// loop back again and reverify the metadata // loop back again and reverify the metadata
continue; continue;
@@ -419,7 +420,7 @@ public abstract class Getdown extends Thread
setStatus("m.validating", -1, -1L, false); setStatus("m.validating", -1, -1L, false);
List<Resource> failures = _app.verifyResources(_progobs, alreadyValid); List<Resource> failures = _app.verifyResources(_progobs, alreadyValid);
if (failures == null) { if (failures == null) {
Log.info("Resources verified."); log.info("Resources verified.");
// Only launch if we aren't in silent mode. Some mystery program starting out // Only launch if we aren't in silent mode. Some mystery program starting out
// of the blue would be disconcerting. // of the blue would be disconcerting.
if (!_silent || _launchInSilent) { if (!_silent || _launchInSilent) {
@@ -442,7 +443,7 @@ public abstract class Getdown extends Thread
reportTrackingEvent("app_start", -1); reportTrackingEvent("app_start", -1);
// redownload any that are corrupt or invalid... // redownload any that are corrupt or invalid...
Log.info(failures.size() + " of " + _app.getAllResources().size() + log.info(failures.size() + " of " + _app.getAllResources().size() +
" rsrcs require update (" + alreadyValid[0] + " assumed valid)."); " rsrcs require update (" + alreadyValid[0] + " assumed valid).");
download(failures); download(failures);
@@ -454,11 +455,11 @@ public abstract class Getdown extends Thread
// now we'll loop back and try it all again // now we'll loop back and try it all again
} }
Log.warning("Pants! We couldn't get the job done."); log.warning("Pants! We couldn't get the job done.");
throw new IOException("m.unable_to_repair"); throw new IOException("m.unable_to_repair");
} catch (Exception e) { } catch (Exception e) {
Log.logStackTrace(e); log.warning("getdown() failed.", e);
String msg = e.getMessage(); String msg = e.getMessage();
if (msg == null) { if (msg == null) {
msg = MessageUtil.compose("m.unknown_error", _ifc.installError); msg = MessageUtil.compose("m.unknown_error", _ifc.installError);
@@ -511,7 +512,7 @@ public abstract class Getdown extends Thread
imgpath = _app.getLocalPath(path); imgpath = _app.getLocalPath(path);
return ImageIO.read(imgpath); return ImageIO.read(imgpath);
} catch (IOException ioe2) { } catch (IOException ioe2) {
Log.warning("Failed to load image [path=" + imgpath + ", error=" + ioe2 + "]."); log.warning("Failed to load image [path=" + imgpath + ", error=" + ioe2 + "].");
return null; return null;
} }
} }
@@ -551,10 +552,10 @@ public abstract class Getdown extends Thread
File.separator + "java"; File.separator + "java";
String cmd = "chmod a+rx " + _app.getLocalPath(vmbin); String cmd = "chmod a+rx " + _app.getLocalPath(vmbin);
try { try {
Log.info("Please smack a Java engineer. Running: " + cmd); log.info("Please smack a Java engineer. Running: " + cmd);
Runtime.getRuntime().exec(cmd); Runtime.getRuntime().exec(cmd);
} catch (Exception e) { } catch (Exception e) {
Log.warning("Failed to mark VM binary as executable [cmd=" + cmd + log.warning("Failed to mark VM binary as executable [cmd=" + cmd +
", error=" + e + "]."); ", error=" + e + "].");
// we should do something like tell the user or something but fucking fuck // we should do something like tell the user or something but fucking fuck
} }
@@ -563,10 +564,10 @@ public abstract class Getdown extends Thread
// lastly regenerate the .jsa dump file that helps Java to start up faster // lastly regenerate the .jsa dump file that helps Java to start up faster
String vmpath = LaunchUtil.getJVMPath(_app.getLocalPath("")); String vmpath = LaunchUtil.getJVMPath(_app.getLocalPath(""));
try { try {
Log.info("Regenerating classes.jsa for " + vmpath + "..."); log.info("Regenerating classes.jsa for " + vmpath + "...");
Runtime.getRuntime().exec(vmpath + " -Xshare:dump"); Runtime.getRuntime().exec(vmpath + " -Xshare:dump");
} catch (Exception e) { } catch (Exception e) {
Log.warning("Failed to regenerate .jsa dum file [error=" + e + "]."); log.warning("Failed to regenerate .jsa dum file [error=" + e + "].");
} }
reportTrackingEvent("jvm_complete", -1); reportTrackingEvent("jvm_complete", -1);
@@ -607,13 +608,12 @@ public abstract class Getdown extends Thread
Patcher patcher = new Patcher(); Patcher patcher = new Patcher();
patcher.patch(prsrc.getLocal().getParentFile(), prsrc.getLocal(), _progobs); patcher.patch(prsrc.getLocal().getParentFile(), prsrc.getLocal(), _progobs);
} catch (Exception e) { } catch (Exception e) {
Log.warning("Failed to apply patch [prsrc=" + prsrc + "]."); log.warning("Failed to apply patch [prsrc=" + prsrc + "].", e);
Log.logStackTrace(e);
} }
// clean up the patch file // clean up the patch file
if (!prsrc.getLocal().delete()) { if (!prsrc.getLocal().delete()) {
Log.warning("Failed to delete '" + prsrc + "'."); log.warning("Failed to delete '" + prsrc + "'.");
prsrc.getLocal().deleteOnExit(); prsrc.getLocal().deleteOnExit();
} }
} }
@@ -670,8 +670,7 @@ public abstract class Getdown extends Thread
public void downloadFailed (Resource rsrc, Exception e) { public void downloadFailed (Resource rsrc, Exception e) {
updateStatus(MessageUtil.tcompose("m.failure", e.getMessage())); updateStatus(MessageUtil.tcompose("m.failure", e.getMessage()));
Log.warning("Download failed [rsrc=" + rsrc + "]."); log.warning("Download failed [rsrc=" + rsrc + "].", e);
Log.logStackTrace(e);
} }
/** The last percentage at which we checked for another getdown running, or -1 for not /** The last percentage at which we checked for another getdown running, or -1 for not
@@ -736,7 +735,7 @@ public abstract class Getdown extends Thread
disposeContainer(); disposeContainer();
_status = null; _status = null;
copyStream(stderr, System.err); copyStream(stderr, System.err);
Log.info("Process exited: " + proc.waitFor()); log.info("Process exited: " + proc.waitFor());
} else { } else {
// spawn a daemon thread that will catch the early bits of stderr in case the // spawn a daemon thread that will catch the early bits of stderr in case the
@@ -764,7 +763,7 @@ public abstract class Getdown extends Thread
exit(0); exit(0);
} catch (Exception e) { } catch (Exception e) {
Log.logStackTrace(e); log.warning("launch() failed.", e);
} }
} }
@@ -813,7 +812,7 @@ public abstract class Getdown extends Thread
{ {
if (_ifc.rotatingBackgrounds != null) { if (_ifc.rotatingBackgrounds != null) {
if (_ifc.backgroundImage != null) { if (_ifc.backgroundImage != null) {
Log.warning("ui.background_image and ui.rotating_background were both specified. " + log.warning("ui.background_image and ui.rotating_background were both specified. " +
"The rotating images are being used."); "The rotating images are being used.");
} }
return new RotatingBackgrounds(_ifc.rotatingBackgrounds, _ifc.errorBackground, return new RotatingBackgrounds(_ifc.rotatingBackgrounds, _ifc.errorBackground,
@@ -865,7 +864,7 @@ public abstract class Getdown extends Thread
public void run () { public void run () {
if (_status == null) { if (_status == null) {
if (message != null) { if (message != null) {
Log.info("Dropping status '" + message + "'."); log.info("Dropping status '" + message + "'.");
} }
return; return;
} }
@@ -956,7 +955,7 @@ public abstract class Getdown extends Thread
out.flush(); out.flush();
} }
} catch (IOException ioe) { } catch (IOException ioe) {
Log.warning("Failure copying [in=" + in + ", out=" + out + ", error=" + ioe + "]."); log.warning("Failure copying [in=" + in + ", out=" + out + ", error=" + ioe + "].");
} }
} }
@@ -985,7 +984,7 @@ public abstract class Getdown extends Thread
ucon.connect(); ucon.connect();
try { try {
if (ucon.getResponseCode() != HttpURLConnection.HTTP_OK) { if (ucon.getResponseCode() != HttpURLConnection.HTTP_OK) {
Log.warning("Failed to report tracking event [url=" + _url + log.warning("Failed to report tracking event [url=" + _url +
", rcode=" + ucon.getResponseCode() + "]."); ", rcode=" + ucon.getResponseCode() + "].");
} }
} finally { } finally {
@@ -993,7 +992,7 @@ public abstract class Getdown extends Thread
} }
} catch (IOException ioe) { } catch (IOException ioe) {
Log.warning("Failed to report tracking event [url=" + _url + log.warning("Failed to report tracking event [url=" + _url +
", error=" + ioe + "]."); ", error=" + ioe + "].");
} }
} }
@@ -34,7 +34,7 @@ import java.io.PrintStream;
import com.samskivert.swing.util.SwingUtil; import com.samskivert.swing.util.SwingUtil;
import com.samskivert.util.StringUtil; import com.samskivert.util.StringUtil;
import com.threerings.getdown.Log; import static com.threerings.getdown.Log.log;
/** /**
* Does something extraordinary. * Does something extraordinary.
@@ -65,35 +65,34 @@ public class GetdownApp
// ensure a valid directory was supplied // ensure a valid directory was supplied
File appDir = new File(adarg); File appDir = new File(adarg);
if (!appDir.exists() || !appDir.isDirectory()) { if (!appDir.exists() || !appDir.isDirectory()) {
Log.warning("Invalid app_dir '" + adarg + "'."); log.warning("Invalid app_dir '" + adarg + "'.");
System.exit(-1); System.exit(-1);
} }
// pipe our output into a file in the application directory // pipe our output into a file in the application directory
if (System.getProperty("no_log_redir") == null) { if (System.getProperty("no_log_redir") == null) {
File log = new File(appDir, "launcher.log"); File logFile = new File(appDir, "launcher.log");
try { try {
PrintStream logOut = new PrintStream( PrintStream logOut = new PrintStream(
new BufferedOutputStream(new FileOutputStream(log)), true); new BufferedOutputStream(new FileOutputStream(logFile)), true);
System.setOut(logOut); System.setOut(logOut);
System.setErr(logOut); System.setErr(logOut);
} catch (IOException ioe) { } catch (IOException ioe) {
Log.warning("Unable to redirect output to '" + log + log.warning("Unable to redirect output to '" + logFile + "': " + ioe);
"': " + ioe);
} }
} }
// record a few things for posterity // record a few things for posterity
Log.info("------------------ VM Info ------------------"); log.info("------------------ VM Info ------------------");
Log.info("-- OS Name: " + System.getProperty("os.name")); log.info("-- OS Name: " + System.getProperty("os.name"));
Log.info("-- OS Arch: " + System.getProperty("os.arch")); log.info("-- OS Arch: " + System.getProperty("os.arch"));
Log.info("-- OS Vers: " + System.getProperty("os.version")); log.info("-- OS Vers: " + System.getProperty("os.version"));
Log.info("-- Java Vers: " + System.getProperty("java.version")); log.info("-- Java Vers: " + System.getProperty("java.version"));
Log.info("-- Java Home: " + System.getProperty("java.home")); log.info("-- Java Home: " + System.getProperty("java.home"));
Log.info("-- User Name: " + System.getProperty("user.name")); log.info("-- User Name: " + System.getProperty("user.name"));
Log.info("-- User Home: " + System.getProperty("user.home")); log.info("-- User Home: " + System.getProperty("user.home"));
Log.info("-- Cur dir: " + System.getProperty("user.dir")); log.info("-- Cur dir: " + System.getProperty("user.dir"));
Log.info("---------------------------------------------"); log.info("---------------------------------------------");
try { try {
Getdown app = new Getdown(appDir, appId) { Getdown app = new Getdown(appDir, appId) {
@@ -135,8 +134,9 @@ public class GetdownApp
protected JFrame _frame; protected JFrame _frame;
}; };
app.start(); app.start();
} catch (Exception e) { } catch (Exception e) {
Log.logStackTrace(e); log.warning("main() failed.", e);
} }
} }
} }
@@ -31,10 +31,18 @@ import java.net.URL;
import javax.swing.JApplet; import javax.swing.JApplet;
import javax.swing.JPanel; import javax.swing.JPanel;
import java.io.IOException;
import java.io.FileOutputStream;
import java.io.File;
import java.io.PrintStream;
import java.util.Map;
import com.samskivert.util.RunAnywhere; import com.samskivert.util.RunAnywhere;
import com.samskivert.util.StringUtil; import com.samskivert.util.StringUtil;
import com.threerings.getdown.Log; import com.threerings.getdown.util.ConfigUtil;
import static com.threerings.getdown.Log.log;
/** /**
* An applet that can be used to launch a Getdown application (when signed and * An applet that can be used to launch a Getdown application (when signed and
@@ -68,24 +76,24 @@ public class GetdownApplet extends JApplet
bgimages = new RotatingBackgrounds(loadImage(imgpath)); bgimages = new RotatingBackgrounds(loadImage(imgpath));
} }
Log.info("App Base: " + appbase); log.info("App Base: " + appbase);
Log.info("App Name: " + appname); log.info("App Name: " + appname);
File appdir = null; File appdir = null;
try { try {
appdir = initGetdown(appbase, appname, imgpath); appdir = initGetdown(appbase, appname, imgpath);
// record a few things for posterity // record a few things for posterity
Log.info("------------------ VM Info ------------------"); log.info("------------------ VM Info ------------------");
Log.info("-- OS Name: " + System.getProperty("os.name")); log.info("-- OS Name: " + System.getProperty("os.name"));
Log.info("-- OS Arch: " + System.getProperty("os.arch")); log.info("-- OS Arch: " + System.getProperty("os.arch"));
Log.info("-- OS Vers: " + System.getProperty("os.version")); log.info("-- OS Vers: " + System.getProperty("os.version"));
Log.info("-- Java Vers: " + System.getProperty("java.version")); log.info("-- Java Vers: " + System.getProperty("java.version"));
Log.info("-- Java Home: " + System.getProperty("java.home")); log.info("-- Java Home: " + System.getProperty("java.home"));
Log.info("-- User Name: " + System.getProperty("user.name")); log.info("-- User Name: " + System.getProperty("user.name"));
Log.info("-- User Home: " + System.getProperty("user.home")); log.info("-- User Home: " + System.getProperty("user.home"));
Log.info("-- Cur dir: " + System.getProperty("user.dir")); log.info("-- Cur dir: " + System.getProperty("user.dir"));
Log.info("---------------------------------------------"); log.info("---------------------------------------------");
} catch (Exception e) { } catch (Exception e) {
_errmsg = e.getMessage(); _errmsg = e.getMessage();
@@ -139,7 +147,7 @@ public class GetdownApplet extends JApplet
try { try {
dest = new URL(getParameter("redirect_on_finish")); dest = new URL(getParameter("redirect_on_finish"));
} catch (MalformedURLException e) { } catch (MalformedURLException e) {
Log.warning("URL in redirect_on_finish param is malformed: " + e); log.warning("URL in redirect_on_finish param is malformed: " + e);
return; return;
} }
String target = getParameter("redirect_on_finish_target"); String target = getParameter("redirect_on_finish_target");
@@ -156,7 +164,7 @@ public class GetdownApplet extends JApplet
_getdown.preInit(); _getdown.preInit();
} catch (Exception e) { } catch (Exception e) {
Log.logStackTrace(e); log.warning("init() failed.", e);
} }
} }
@@ -165,8 +173,7 @@ public class GetdownApplet extends JApplet
try { try {
return getImage(new URL(getDocumentBase(), path)); return getImage(new URL(getDocumentBase(), path));
} catch (MalformedURLException e) { } catch (MalformedURLException e) {
Log.warning("Failed to load background image [path=" + path + "]."); log.warning("Failed to load background image", "path", path, e);
Log.logStackTrace(e);
return null; return null;
} }
} }
@@ -180,7 +187,7 @@ public class GetdownApplet extends JApplet
try { try {
_getdown.start(); _getdown.start();
} catch (Exception e) { } catch (Exception e) {
Log.logStackTrace(e); log.warning("start() failed.", e);
} }
} }
} }
@@ -213,7 +220,7 @@ public class GetdownApplet extends JApplet
sm.checkWrite("getdown"); sm.checkWrite("getdown");
sm.checkPropertiesAccess(); sm.checkPropertiesAccess();
} catch (SecurityException se) { } catch (SecurityException se) {
Log.warning("Signed applet rejected by user [se=" + se + "]."); log.warning("Signed applet rejected by user", "se", se);
throw new Exception("m.insufficient_permissions_error"); throw new Exception("m.insufficient_permissions_error");
} }
} }
@@ -240,7 +247,7 @@ public class GetdownApplet extends JApplet
root = "AppData" + File.separator + "LocalLow"; root = "AppData" + File.separator + "LocalLow";
} }
} catch (Exception e) { } catch (Exception e) {
Log.warning("Couldn't parse OS version [vers=" + verStr + ", error=" + e + "]."); log.warning("Couldn't parse OS version", "vers", verStr, "error", e);
} }
} else if (RunAnywhere.isMacOS()) { } else if (RunAnywhere.isMacOS()) {
root = "Library" + File.separator + "Application Support"; root = "Library" + File.separator + "Application Support";
@@ -266,9 +273,25 @@ public class GetdownApplet extends JApplet
} }
} }
// if our getdown.txt file does not exist, auto-create it // if our getdown.txt file does not exist, or it is corrupt, auto-/recreate it
File gdfile = new File(appdir, "getdown.txt"); File gdfile = new File(appdir, "getdown.txt");
if (!gdfile.exists()) { boolean createGetdown = !gdfile.exists();
if (!createGetdown) {
try {
Map<String,Object> cdata = ConfigUtil.parseConfig(gdfile, false);
String oappbase = StringUtil.trim((String)cdata.get("appbase"));
createGetdown = (appbase != null && !appbase.trim().equals(oappbase));
if (createGetdown) {
log.warning("Recreating getdown.txt due to appbase mismatch",
"nappbase", appbase, "oappbase", oappbase);
}
} catch (Exception e) {
log.warning("Failure checking validity of getdown.txt, forcing recreate.",
"error", e);
createGetdown = true;
}
}
if (createGetdown) {
if (StringUtil.isBlank(appbase)) { if (StringUtil.isBlank(appbase)) {
throw new Exception("m.missing_appbase"); throw new Exception("m.missing_appbase");
} }
@@ -291,8 +314,7 @@ public class GetdownApplet extends JApplet
out.close(); out.close();
return true; return true;
} catch (IOException ioe) { } catch (IOException ioe) {
Log.warning("Failed to create '" + tofile + "'."); log.warning("Failed to create '" + tofile + "'.", ioe);
Log.logStackTrace(ioe);
return false; return false;
} }
} }
@@ -39,7 +39,7 @@ import com.samskivert.swing.Spacer;
import com.samskivert.swing.VGroupLayout; import com.samskivert.swing.VGroupLayout;
import com.samskivert.text.MessageUtil; import com.samskivert.text.MessageUtil;
import com.threerings.getdown.Log; import static com.threerings.getdown.Log.log;
/** /**
* Displays an interface with which the user can configure their proxy * Displays an interface with which the user can configure their proxy
@@ -134,7 +134,7 @@ public class ProxyPanel extends JPanel
try { try {
return _msgs.getString(key); return _msgs.getString(key);
} catch (MissingResourceException mre) { } catch (MissingResourceException mre) {
Log.warning("Missing translation message '" + key + "'."); log.warning("Missing translation message '" + key + "'.");
return key; return key;
} }
} }
@@ -1,8 +1,28 @@
//
// $Id$
//
// Getdown - application installer, patcher and launcher
// Copyright (C) 2004-2006 Three Rings Design, Inc.
//
// This program is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by the Free
// Software Foundation; either version 2 of the License, or (at your option)
// any later version.
//
// This program is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
// more details.
//
// You should have received a copy of the GNU General Public License along with
// this program; if not, write to the: Free Software Foundation, Inc.,
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
package com.threerings.getdown.launcher; package com.threerings.getdown.launcher;
import java.awt.Image; import java.awt.Image;
import com.threerings.getdown.Log; import static com.threerings.getdown.Log.log;
public class RotatingBackgrounds public class RotatingBackgrounds
{ {
@@ -41,7 +61,7 @@ public class RotatingBackgrounds
for (int ii = 0; ii < backgrounds.length; ii++) { for (int ii = 0; ii < backgrounds.length; ii++) {
String[] pieces = backgrounds[ii].split(";"); String[] pieces = backgrounds[ii].split(";");
if (pieces.length != 2) { if (pieces.length != 2) {
Log.warning("Unable to parse background image '" + backgrounds[ii] + "'"); log.warning("Unable to parse background image '" + backgrounds[ii] + "'");
makeEmpty(); makeEmpty();
return; return;
} }
@@ -49,8 +69,8 @@ public class RotatingBackgrounds
try { try {
minDisplayTime[ii] = Integer.parseInt(pieces[1]); minDisplayTime[ii] = Integer.parseInt(pieces[1]);
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
Log.warning("Unable to parse background image display time '" log.warning("Unable to parse background image display time '" +
+ backgrounds[ii] + "'"); backgrounds[ii] + "'");
makeEmpty(); makeEmpty();
return; return;
} }
@@ -37,9 +37,11 @@ import com.samskivert.swing.util.SwingUtil;
import com.samskivert.text.MessageUtil; import com.samskivert.text.MessageUtil;
import com.samskivert.util.StringUtil; import com.samskivert.util.StringUtil;
import com.samskivert.util.Throttle; import com.samskivert.util.Throttle;
import com.threerings.getdown.Log;
import com.threerings.getdown.data.Application.UpdateInterface; import com.threerings.getdown.data.Application.UpdateInterface;
import static com.threerings.getdown.Log.log;
/** /**
* Displays download and patching status. * Displays download and patching status.
*/ */
@@ -257,7 +259,7 @@ public class StatusPanel extends JComponent
try { try {
return _msgs.getString(key); return _msgs.getString(key);
} catch (MissingResourceException mre) { } catch (MissingResourceException mre) {
Log.warning("Missing translation message '" + key + "'."); log.warning("Missing translation message '" + key + "'.");
return key; return key;
} }
} }
@@ -25,9 +25,10 @@ import java.io.IOException;
import java.util.List; import java.util.List;
import com.threerings.getdown.Log;
import com.threerings.getdown.data.Resource; import com.threerings.getdown.data.Resource;
import static com.threerings.getdown.Log.log;
/** /**
* Handles the download of a collection of files, first issuing HTTP head requests to obtain size * Handles the download of a collection of files, first issuing HTTP head requests to obtain size
* information and then downloading the files individually, reporting progress back via a callback * information and then downloading the files individually, reporting progress back via a callback
@@ -112,7 +113,7 @@ public abstract class Downloader extends Thread
discoverSize(resource); discoverSize(resource);
} }
Log.info("Downloading " + _totalSize + " bytes..."); log.info("Downloading " + _totalSize + " bytes...");
// make a note of the time at which we started the download // make a note of the time at which we started the download
_start = System.currentTimeMillis(); _start = System.currentTimeMillis();
@@ -137,7 +138,7 @@ public abstract class Downloader extends Thread
if (_obs != null) { if (_obs != null) {
_obs.downloadFailed(current, e); _obs.downloadFailed(current, e);
} else { } else {
Log.logStackTrace(e); log.warning("Observer failed.", e);
} }
} }
return true; return true;
@@ -168,7 +169,7 @@ public abstract class Downloader extends Thread
File parent = new File(rsrc.getLocal().getParent()); File parent = new File(rsrc.getLocal().getParent());
if (!parent.exists()) { if (!parent.exists()) {
if (!parent.mkdirs()) { if (!parent.mkdirs()) {
Log.warning("Failed to create target directory for resource '" + rsrc + "'. " + log.warning("Failed to create target directory for resource '" + rsrc + "'. " +
"Download will certainly fail."); "Download will certainly fail.");
} }
} }
@@ -27,9 +27,11 @@ import java.net.HttpURLConnection;
import java.util.List; import java.util.List;
import com.samskivert.io.StreamUtil; import com.samskivert.io.StreamUtil;
import com.threerings.getdown.Log;
import com.threerings.getdown.data.Resource; import com.threerings.getdown.data.Resource;
import static com.threerings.getdown.Log.log;
/** /**
* Implements downloading files over HTTP * Implements downloading files over HTTP
*/ */
@@ -89,7 +91,7 @@ public class HTTPDownloader extends Downloader
throw new IOException(errmsg); throw new IOException(errmsg);
} }
Log.info("Downloading resource [url=" + rsrc.getRemote() + "]."); log.info("Downloading resource [url=" + rsrc.getRemote() + "].");
InputStream in = null; InputStream in = null;
FileOutputStream out = null; FileOutputStream out = null;
try { try {
@@ -27,9 +27,10 @@ import java.util.List;
import org.klomp.snark.Snark; import org.klomp.snark.Snark;
import org.klomp.snark.SnarkShutdown; import org.klomp.snark.SnarkShutdown;
import com.threerings.getdown.Log;
import com.threerings.getdown.data.Resource; import com.threerings.getdown.data.Resource;
import static com.threerings.getdown.Log.log;
/** /**
* Implements downloading data using BitTorrent * Implements downloading data using BitTorrent
*/ */
@@ -38,7 +39,7 @@ public class TorrentDownloader extends Downloader
public TorrentDownloader (List<Resource> resources, Observer obs) public TorrentDownloader (List<Resource> resources, Observer obs)
{ {
super(resources, obs); super(resources, obs);
Log.info("Using bittorrent to fetch files"); log.info("Using bittorrent to fetch files");
for (Resource resource : resources) { for (Resource resource : resources) {
String url = resource.getRemote().toString() + ".torrent"; String url = resource.getRemote().toString() + ".torrent";
Snark snark = new Snark(url, null, -1, null, null); Snark snark = new Snark(url, null, -1, null, null);
@@ -69,7 +70,7 @@ public class TorrentDownloader extends Downloader
snark.setupNetwork(); snark.setupNetwork();
length = snark.meta.getTotalLength(); length = snark.meta.getTotalLength();
} catch (IOException ioe) { } catch (IOException ioe) {
Log.warning("Bittorrent failed, falling back to HTTP"); log.warning("Bittorrent failed, falling back to HTTP");
SnarkShutdown stopper = _stoppermap.get(rsrc); SnarkShutdown stopper = _stoppermap.get(rsrc);
stopper.run(); stopper.run();
Runtime.getRuntime().removeShutdownHook(stopper); Runtime.getRuntime().removeShutdownHook(stopper);
@@ -111,7 +112,7 @@ public class TorrentDownloader extends Downloader
_currentSize = snark.coordinator.getDownloaded(); _currentSize = snark.coordinator.getDownloaded();
if ((_currentSize < SIZE_THRESHOLD && if ((_currentSize < SIZE_THRESHOLD &&
(now - _start) >= TIME_THRESHOLD)) { (now - _start) >= TIME_THRESHOLD)) {
Log.info("Torrenting too slow, falling back to HTTP."); log.info("Torrenting too slow, falling back to HTTP.");
// The download isn't going as planned, abort; // The download isn't going as planned, abort;
snarkStopper.run(); snarkStopper.run();
Runtime.getRuntime().removeShutdownHook(snarkStopper); Runtime.getRuntime().removeShutdownHook(snarkStopper);
@@ -32,10 +32,11 @@ import java.util.zip.ZipEntry;
import com.samskivert.io.StreamUtil; import com.samskivert.io.StreamUtil;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
import com.threerings.getdown.Log;
import com.threerings.getdown.util.FileUtil; import com.threerings.getdown.util.FileUtil;
import com.threerings.getdown.util.ProgressObserver; import com.threerings.getdown.util.ProgressObserver;
import static com.threerings.getdown.Log.log;
/** /**
* Applies a unified patch file to an application directory, providing * Applies a unified patch file to an application directory, providing
* percentage completion feedback along the way. <em>Note:</em> the * percentage completion feedback along the way. <em>Note:</em> the
@@ -122,7 +123,7 @@ public class Patcher
File pdir = target.getParentFile(); File pdir = target.getParentFile();
if (!pdir.exists()) { if (!pdir.exists()) {
if (!pdir.mkdirs()) { if (!pdir.mkdirs()) {
Log.warning("Failed to create parent for '" + target + "'."); log.warning("Failed to create parent for '" + target + "'.");
} }
} }
@@ -34,7 +34,7 @@ import java.util.List;
import com.samskivert.io.StreamUtil; import com.samskivert.io.StreamUtil;
import com.samskivert.util.StringUtil; import com.samskivert.util.StringUtil;
import com.threerings.getdown.Log; import static com.threerings.getdown.Log.log;
/** /**
* Parses a file containing key/value pairs and returns a {@link HashMap} with the values. Keys may * Parses a file containing key/value pairs and returns a {@link HashMap} with the values. Keys may
@@ -90,7 +90,7 @@ public class ConfigUtil
if (pair[1].startsWith("[")) { if (pair[1].startsWith("[")) {
cidx = pair[1].indexOf("]"); cidx = pair[1].indexOf("]");
if (cidx == -1) { if (cidx == -1) {
Log.warning("Bogus platform specifier [key=" + pair[0] + log.warning("Bogus platform specifier [key=" + pair[0] +
", value=" + pair[1] + "]."); ", value=" + pair[1] + "].");
} else { } else {
String platform = pair[1].substring(1, cidx); String platform = pair[1].substring(1, cidx);
@@ -100,12 +100,12 @@ public class ConfigUtil
if (platform.startsWith("!")) { if (platform.startsWith("!")) {
platform = platform.substring(1); platform = platform.substring(1);
if (osname.indexOf(platform) != -1) { if (osname.indexOf(platform) != -1) {
Log.info("Skipping [platform=!" + platform + log.info("Skipping [platform=!" + platform +
", key=" + pair[0] + ", value=" + pair[1] + "]."); ", key=" + pair[0] + ", value=" + pair[1] + "].");
continue; continue;
} }
} else if (osname.indexOf(platform) == -1) { } else if (osname.indexOf(platform) == -1) {
Log.info("Skipping [platform=" + platform + log.info("Skipping [platform=" + platform +
", key=" + pair[0] + ", value=" + pair[1] + "]."); ", key=" + pair[0] + ", value=" + pair[1] + "].");
continue; continue;
} }
@@ -29,7 +29,7 @@ import com.samskivert.io.StreamUtil;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
import com.threerings.getdown.Log; import static com.threerings.getdown.Log.log;
/** /**
* File related utilities. * File related utilities.
@@ -55,14 +55,14 @@ public class FileUtil
File temp = new File(dest.getPath() + "_old"); File temp = new File(dest.getPath() + "_old");
if (temp.exists()) { if (temp.exists()) {
if (!temp.delete()) { if (!temp.delete()) {
Log.warning("Failed to delete old intermediate file " + temp + "."); log.warning("Failed to delete old intermediate file " + temp + ".");
// the subsequent code will probably fail // the subsequent code will probably fail
} }
} }
if (dest.renameTo(temp)) { if (dest.renameTo(temp)) {
if (source.renameTo(dest)) { if (source.renameTo(dest)) {
if (temp.delete()) { if (temp.delete()) {
Log.warning("Failed to delete intermediate file " + temp + "."); log.warning("Failed to delete intermediate file " + temp + ".");
} }
return true; return true;
} }
@@ -77,13 +77,13 @@ public class FileUtil
fout = new FileOutputStream(dest); fout = new FileOutputStream(dest);
IOUtils.copy(fin, fout); IOUtils.copy(fin, fout);
if (!source.delete()) { if (!source.delete()) {
Log.warning("Failed to delete " + source + log.warning("Failed to delete " + source +
" after brute force copy to " + dest + "."); " after brute force copy to " + dest + ".");
} }
return true; return true;
} catch (IOException ioe) { } catch (IOException ioe) {
Log.warning("Failed to copy " + source + " to " + dest + ": " + ioe); log.warning("Failed to copy " + source + " to " + dest + ": " + ioe);
return false; return false;
} finally { } finally {
@@ -90,7 +90,7 @@ public class LaunchUtil
Runtime.getRuntime().exec(args, null); Runtime.getRuntime().exec(args, null);
return true; return true;
} catch (IOException ioe) { } catch (IOException ioe) {
log.log(Level.WARNING, "Failed to run getdown", ioe); log.warning("Failed to run getdown", ioe);
return false; return false;
} }
} }
@@ -136,7 +136,7 @@ public class LaunchUtil
vmpath = "/usr/bin/java"; vmpath = "/usr/bin/java";
} }
} catch (IOException ioe) { } catch (IOException ioe) {
log.log(Level.WARNING, "Failed to check Mac OS canonical VM path.", ioe); log.warning("Failed to check Mac OS canonical VM path.", ioe);
} }
} }
@@ -192,7 +192,7 @@ public class LaunchUtil
try { try {
IOUtils.copy(new FileInputStream(newgd), new FileOutputStream(curgd)); IOUtils.copy(new FileInputStream(newgd), new FileOutputStream(curgd));
} catch (IOException ioe) { } catch (IOException ioe) {
log.log(Level.WARNING, "Mayday! Brute force copy method also failed.", ioe); log.warning("Mayday! Brute force copy method also failed.", ioe);
} }
} }