From 29b8e875dedee49ac393a1ef154183e6826692ba Mon Sep 17 00:00:00 2001 From: Michael Bayne Date: Wed, 14 Mar 2007 19:09:00 +0000 Subject: [PATCH] Progress reporting fixes. --- .../threerings/getdown/data/Application.java | 8 ++++++- .../threerings/getdown/launcher/Getdown.java | 24 +++++++++++++------ 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/src/java/com/threerings/getdown/data/Application.java b/src/java/com/threerings/getdown/data/Application.java index ca9470b..e8bf6d1 100644 --- a/src/java/com/threerings/getdown/data/Application.java +++ b/src/java/com/threerings/getdown/data/Application.java @@ -882,8 +882,11 @@ public class Application * Verifies the code and media resources associated with this application. A list of resources * that do not exist or fail the verification process will be returned. If all resources are * ready to go, null will be returned and the application is considered ready to run. + * + * @param alreadyValid if non-null a 1 element array that will have the number of "already + * validated" resources filled in. */ - public List verifyResources (ProgressObserver obs) + public List verifyResources (ProgressObserver obs, int[] alreadyValid) { List rsrcs = getAllResources(); List failures = new ArrayList(); @@ -899,6 +902,9 @@ public class Application mpobs.startElement(rsrc.getLocal().length()); if (rsrc.isMarkedValid()) { + if (alreadyValid != null) { + alreadyValid[0]++; + } mpobs.progress(100); continue; } diff --git a/src/java/com/threerings/getdown/launcher/Getdown.java b/src/java/com/threerings/getdown/launcher/Getdown.java index b2767c1..1ff2499 100644 --- a/src/java/com/threerings/getdown/launcher/Getdown.java +++ b/src/java/com/threerings/getdown/launcher/Getdown.java @@ -340,6 +340,14 @@ public abstract class Getdown extends Thread createInterface(true); } + // we create this tracking counter here so that we properly note the first time through + // the update process whether we previously had validated resources (which means this + // is not a first time install); we may, in the course of updating, wipe out our + // validation markers and revalidate which would make us think we were doing a fresh + // install if we didn't specifically remember that we had validated resources the first + // time through + int[] alreadyValid = new int[1]; + for (int ii = 0; ii < MAX_LOOPS; ii++) { // if we aren't running in a JVM that meets our version requirements, either // complain or attempt to download and install the appropriate version @@ -367,7 +375,7 @@ public abstract class Getdown extends Thread // now verify our resources... setStatus("m.validating", -1, -1L, false); - List failures = _app.verifyResources(_progobs); + List failures = _app.verifyResources(_progobs, alreadyValid); if (failures == null) { Log.info("Resources verified."); launch(); @@ -375,12 +383,14 @@ public abstract class Getdown extends Thread } try { - int rcount = _app.getAllResources().size(); - _enableTracking = (failures.size() == rcount); + // if any of our resources have already been marked valid this is not a first + // time install and we don't want to enable tracking + _enableTracking = (alreadyValid[0] == 0); reportTrackingEvent("app_start", -1); // redownload any that are corrupt or invalid... - Log.info(failures.size() + " of " + rcount + " rsrcs require update."); + Log.info(failures.size() + " of " + _app.getAllResources().size() + + " rsrcs require update (" + alreadyValid[0] + " assumed valid)."); download(failures); reportTrackingEvent("app_complete", -1); @@ -747,12 +757,12 @@ public abstract class Getdown extends Thread } else if (progress > 0) { // we need to make sure we do the right thing if we skip over progress levels - for (int ii = _reportedProgress+1; ii <= progress; ii++) { - URL url = _app.getTrackingProgressURL(progress); + do { + URL url = _app.getTrackingProgressURL(++_reportedProgress); if (url != null) { new ProgressReporter(url).start(); } - } + } while (_reportedProgress <= progress); } else { URL url = _app.getTrackingURL(event);