From c7e7da830a6cc5262cbebd35e87ab345f3ebd4b6 Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Wed, 5 Jan 2011 00:09:52 +0000 Subject: [PATCH] Allow specifying a "latest" attribute containing the URL of the latest getdown.txt (from which we retrieve the most recent version). --- .../threerings/getdown/data/Application.java | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/main/java/com/threerings/getdown/data/Application.java b/src/main/java/com/threerings/getdown/data/Application.java index f8c5bba..dcd14f1 100644 --- a/src/main/java/com/threerings/getdown/data/Application.java +++ b/src/main/java/com/threerings/getdown/data/Application.java @@ -468,6 +468,16 @@ public class Application throw (IOException) new IOException(err).initCause(mue); } + // check for a latest config URL + String latest = (String)cdata.get("latest"); + if (latest != null) { + try { + _latest = new URL(latest); + } catch (MalformedURLException mue) { + log.warning("Invalid URL for latest attribute.", mue); + } + } + String prefix = (_appid == null) ? "" : (_appid + "."); // determine our application class name @@ -1000,6 +1010,7 @@ public class Application _targetVersion = _version; // if we are a versioned application, read in the contents of the version.txt file + // and/or check the latest config URL for a newer version if (_version != -1) { File vfile = getLocalPath(VERSION_FILE); FileInputStream fin = null; @@ -1015,6 +1026,24 @@ public class Application } finally { StreamUtil.close(fin); } + + if (_latest != null) { + InputStream in = null; + try { + in = _latest.openStream(); + BufferedReader bin = new BufferedReader(new InputStreamReader(in)); + for (String[] pair : ConfigUtil.parsePairs(bin, false)) { + if (pair[0].equals("version")) { + _targetVersion = Long.parseLong(pair[1]); + break; + } + } + } catch (Exception e) { + log.warning("Unable to retrieve version from latest config file.", e); + } finally { + StreamUtil.close(in); + } + } } // finally let the caller know if we need an update @@ -1425,6 +1454,7 @@ public class Application protected long _targetVersion = -1; protected String _appbase; protected URL _vappbase; + protected URL _latest; protected String _class; protected String _name; protected String _dockIconPath;