diff --git a/src/main/java/com/threerings/getdown/data/Application.java b/src/main/java/com/threerings/getdown/data/Application.java index 75fd416..d410e7e 100644 --- a/src/main/java/com/threerings/getdown/data/Application.java +++ b/src/main/java/com/threerings/getdown/data/Application.java @@ -225,6 +225,21 @@ public class Application public void updateStatus (String message); } + /** + * Contains metadata for an auxiliary resource group. + */ + public static class AuxGroup { + public final String name; + public final List codes; + public final List rsrcs; + + public AuxGroup (String name, List codes, List rsrcs) { + this.name = name; + this.codes = Collections.unmodifiableList(codes); + this.rsrcs = Collections.unmodifiableList(rsrcs); + } + } + /** * Creates an application instance with no signers. * @@ -298,13 +313,21 @@ public class Application } /** - * Returns a list of all auxiliary resource groups defined by the application. An auxiliary + * Returns the auxiliary resource group with the specified name, or null. + */ + public AuxGroup getAuxGroup (String name) + { + return _auxgroups.get(name); + } + + /** + * Returns the set of all auxiliary resource groups defined by the application. An auxiliary * resource group is a collection of resource files that are not downloaded unless a group * token file is present in the application directory. */ - public List getAuxGroups () + public Iterable getAuxGroups () { - return _auxgroups; + return _auxgroups.values(); } /** @@ -325,14 +348,18 @@ public class Application } /** - * Returns a list of the non-code {@link Resource} objects included in the specified auxiliary - * resource group. If the group does not exist or has no resources, an empty list will be - * returned. + * Returns all main code resources and all code resources from active auxiliary resource groups. */ - public List getResources (String group) + public List getActiveCodeResources () { - ArrayList auxrsrcs = _auxrsrcs.get(group); - return (auxrsrcs == null) ? new ArrayList() : auxrsrcs; + ArrayList codes = new ArrayList(); + codes.addAll(getCodeResources()); + for (AuxGroup aux : getAuxGroups()) { + if (isAuxGroupActive(aux.name)) { + codes.addAll(aux.codes); + } + } + return codes; } /** @@ -342,9 +369,9 @@ public class Application { ArrayList rsrcs = new ArrayList(); rsrcs.addAll(getResources()); - for (String auxgroup : getAuxGroups()) { - if (isAuxGroupActive(auxgroup)) { - rsrcs.addAll(getResources(auxgroup)); + for (AuxGroup aux : getAuxGroups()) { + if (isAuxGroupActive(aux.name)) { + rsrcs.addAll(aux.rsrcs); } } return rsrcs; @@ -596,7 +623,6 @@ public class Application _codes.clear(); _resources.clear(); _auxgroups.clear(); - _auxrsrcs.clear(); _jvmargs.clear(); _appargs.clear(); _txtJvmArgs.clear(); @@ -613,11 +639,12 @@ public class Application // parse our auxiliary resource groups for (String auxgroup : parseList(cdata, "auxgroups")) { + ArrayList codes = new ArrayList(); + parseResources(cdata, auxgroup + ".code", false, codes); ArrayList rsrcs = new ArrayList(); parseResources(cdata, auxgroup + ".resource", false, rsrcs); parseResources(cdata, auxgroup + ".uresource", true, rsrcs); - _auxrsrcs.put(auxgroup, rsrcs); - _auxgroups.add(auxgroup); + _auxgroups.put(auxgroup, new AuxGroup(auxgroup, codes, rsrcs)); } // transfer our JVM arguments @@ -865,7 +892,7 @@ public class Application { // create our classpath StringBuilder cpbuf = new StringBuilder(); - for (Resource rsrc : _codes) { + for (Resource rsrc : getActiveCodeResources()) { if (cpbuf.length() > 0) { cpbuf.append(File.pathSeparator); } @@ -972,7 +999,7 @@ public class Application { // create a custom class loader ArrayList jars = new ArrayList(); - for (Resource rsrc : _codes) { + for (Resource rsrc : getActiveCodeResources()) { try { jars.add(new URL("file", "", rsrc.getLocal().getAbsolutePath())); } catch (Exception e) { @@ -1669,8 +1696,7 @@ public class Application protected List _codes = new ArrayList(); protected List _resources = new ArrayList(); - protected List _auxgroups = new ArrayList(); - protected Map> _auxrsrcs = new HashMap>(); + protected Map _auxgroups = new HashMap(); protected Map _auxactive = new HashMap(); protected List _jvmargs = new ArrayList(); @@ -1688,11 +1714,11 @@ public class Application /** If a warning has been issued about not being able to set modtimes. */ protected boolean _warnedAboutSetLastModified; - protected static final String[] SA_PROTO = ArrayUtil.EMPTY_STRING; - /** Locks gettingdown.lock in the app dir. Held the entire time updating is going on.*/ protected FileLock _lock; /** Channel to the file underlying _lock. Kept around solely so the lock doesn't close. */ protected FileChannel _lockChannel; + + protected static final String[] SA_PROTO = ArrayUtil.EMPTY_STRING; } diff --git a/src/main/java/com/threerings/getdown/launcher/Getdown.java b/src/main/java/com/threerings/getdown/launcher/Getdown.java index 671f6da..747ed86 100644 --- a/src/main/java/com/threerings/getdown/launcher/Getdown.java +++ b/src/main/java/com/threerings/getdown/launcher/Getdown.java @@ -654,9 +654,9 @@ public abstract class Getdown extends Thread list.add(patch); // add the auxiliary group patch files for activated groups - for (String auxgroup : _app.getAuxGroups()) { - if (_app.isAuxGroupActive(auxgroup)) { - patch = _app.getPatchResource(auxgroup); + for (Application.AuxGroup aux : _app.getAuxGroups()) { + if (_app.isAuxGroupActive(aux.name)) { + patch = _app.getPatchResource(aux.name); if (patch != null) { list.add(patch); } diff --git a/src/main/java/com/threerings/getdown/tools/Differ.java b/src/main/java/com/threerings/getdown/tools/Differ.java index e947748..ceacb1e 100644 --- a/src/main/java/com/threerings/getdown/tools/Differ.java +++ b/src/main/java/com/threerings/getdown/tools/Differ.java @@ -95,12 +95,17 @@ public class Differ createPatch(patch, orsrcs, nrsrcs, verbose); // next create patches for any auxiliary resource groups - for (String auxgroup : napp.getAuxGroups()) { + for (Application.AuxGroup ag : napp.getAuxGroups()) { orsrcs = new ArrayList(); - orsrcs.addAll(oapp.getResources(auxgroup)); + Application.AuxGroup oag = oapp.getAuxGroup(ag.name); + if (oag != null) { + orsrcs.addAll(oag.codes); + orsrcs.addAll(oag.rsrcs); + } nrsrcs = new ArrayList(); - nrsrcs.addAll(napp.getResources(auxgroup)); - patch = new File(nvdir, "patch-" + auxgroup + overs + ".dat"); + nrsrcs.addAll(ag.codes); + nrsrcs.addAll(ag.rsrcs); + patch = new File(nvdir, "patch-" + ag.name + overs + ".dat"); createPatch(patch, orsrcs, nrsrcs, verbose); } } diff --git a/src/main/java/com/threerings/getdown/tools/Digester.java b/src/main/java/com/threerings/getdown/tools/Digester.java index 8c5b3a8..c7ca102 100644 --- a/src/main/java/com/threerings/getdown/tools/Digester.java +++ b/src/main/java/com/threerings/getdown/tools/Digester.java @@ -83,8 +83,9 @@ public class Digester rsrcs.add(app.getConfigResource()); rsrcs.addAll(app.getCodeResources()); rsrcs.addAll(app.getResources()); - for (String auxgroup : app.getAuxGroups()) { - rsrcs.addAll(app.getResources(auxgroup)); + for (Application.AuxGroup ag : app.getAuxGroups()) { + rsrcs.addAll(ag.codes); + rsrcs.addAll(ag.rsrcs); } // now generate the digest file