Order logic a little less weirdly.
This commit is contained in:
@@ -469,80 +469,81 @@ public abstract class Getdown extends Thread
|
|||||||
Set<Resource> toDownload = new HashSet<>();
|
Set<Resource> toDownload = new HashSet<>();
|
||||||
_app.verifyResources(_progobs, alreadyValid, unpacked,
|
_app.verifyResources(_progobs, alreadyValid, unpacked,
|
||||||
_toInstallResources, toDownload);
|
_toInstallResources, toDownload);
|
||||||
if (toDownload.size() == 0) {
|
|
||||||
// if we were downloaded in full from another service (say, Steam), we may
|
|
||||||
// not have unpacked all of our resources yet
|
|
||||||
if (Boolean.getBoolean("check_unpacked")) {
|
|
||||||
File ufile = _app.getLocalPath("unpacked.dat");
|
|
||||||
long version = -1;
|
|
||||||
long aversion = _app.getVersion();
|
|
||||||
if (!ufile.exists()) {
|
|
||||||
ufile.createNewFile();
|
|
||||||
} else {
|
|
||||||
version = VersionUtil.readVersion(ufile);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (version < aversion) {
|
if (toDownload.size() > 0) {
|
||||||
log.info("Performing unpack.",
|
// we have resources to download, also note them as to-be-installed
|
||||||
"version", version, "aversion", aversion);
|
for (Resource r : toDownload) {
|
||||||
setStep(Step.UNPACK);
|
if (!_toInstallResources.contains(r)) {
|
||||||
updateStatus("m.validating");
|
_toInstallResources.add(r);
|
||||||
_app.unpackResources(_progobs, unpacked);
|
|
||||||
try {
|
|
||||||
VersionUtil.writeVersion(ufile, aversion);
|
|
||||||
} catch (IOException ioe) {
|
|
||||||
log.warning("Failed to update unpacked version", ioe);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// assuming we're not doing anything funny, install the update
|
try {
|
||||||
_readyToInstall = true;
|
// if any of our resources have already been marked valid this is not a
|
||||||
if (!_noInstall) {
|
// first time install and we don't want to enable tracking
|
||||||
install();
|
_enableTracking = (alreadyValid[0] == 0);
|
||||||
|
reportTrackingEvent("app_start", -1);
|
||||||
|
|
||||||
|
// redownload any that are corrupt or invalid...
|
||||||
|
log.info(toDownload.size() + " of " + _app.getAllActiveResources().size() +
|
||||||
|
" rsrcs require update (" + alreadyValid[0] + " assumed valid).");
|
||||||
|
setStep(Step.REDOWNLOAD_RESOURCES);
|
||||||
|
download(toDownload);
|
||||||
|
|
||||||
|
reportTrackingEvent("app_complete", -1);
|
||||||
|
|
||||||
|
} finally {
|
||||||
|
_enableTracking = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only launch if we aren't in silent mode. Some mystery program starting out
|
// now we'll loop back and try it all again
|
||||||
// of the blue would be disconcerting.
|
continue;
|
||||||
if (!_silent || _launchInSilent) {
|
}
|
||||||
if (Thread.interrupted()) {
|
|
||||||
// One last interrupted check so we don't launch as the applet aborts
|
// if we were downloaded in full from another service (say, Steam), we may
|
||||||
throw new InterruptedException("m.applet_stopped");
|
// not have unpacked all of our resources yet
|
||||||
|
if (Boolean.getBoolean("check_unpacked")) {
|
||||||
|
File ufile = _app.getLocalPath("unpacked.dat");
|
||||||
|
long version = -1;
|
||||||
|
long aversion = _app.getVersion();
|
||||||
|
if (!ufile.exists()) {
|
||||||
|
ufile.createNewFile();
|
||||||
|
} else {
|
||||||
|
version = VersionUtil.readVersion(ufile);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (version < aversion) {
|
||||||
|
log.info("Performing unpack", "version", version, "aversion", aversion);
|
||||||
|
setStep(Step.UNPACK);
|
||||||
|
updateStatus("m.validating");
|
||||||
|
_app.unpackResources(_progobs, unpacked);
|
||||||
|
try {
|
||||||
|
VersionUtil.writeVersion(ufile, aversion);
|
||||||
|
} catch (IOException ioe) {
|
||||||
|
log.warning("Failed to update unpacked version", ioe);
|
||||||
}
|
}
|
||||||
// And another final check for the lock. It'll already be held unless
|
|
||||||
// we're in silent mode.
|
|
||||||
_app.lockForUpdates();
|
|
||||||
launch();
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// we have resources to download, also note them as to-be-installed
|
|
||||||
for (Resource r : toDownload) {
|
|
||||||
if (!_toInstallResources.contains(r)) {
|
|
||||||
_toInstallResources.add(r);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
// assuming we're not doing anything funny, install the update
|
||||||
// if any of our resources have already been marked valid this is not a first
|
_readyToInstall = true;
|
||||||
// time install and we don't want to enable tracking
|
if (!_noInstall) {
|
||||||
_enableTracking = (alreadyValid[0] == 0);
|
install();
|
||||||
reportTrackingEvent("app_start", -1);
|
|
||||||
|
|
||||||
// redownload any that are corrupt or invalid...
|
|
||||||
log.info(toDownload.size() + " of " + _app.getAllActiveResources().size() +
|
|
||||||
" rsrcs require update (" + alreadyValid[0] + " assumed valid).");
|
|
||||||
setStep(Step.REDOWNLOAD_RESOURCES);
|
|
||||||
download(toDownload);
|
|
||||||
|
|
||||||
reportTrackingEvent("app_complete", -1);
|
|
||||||
|
|
||||||
} finally {
|
|
||||||
_enableTracking = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// now we'll loop back and try it all again
|
// Only launch if we aren't in silent mode. Some mystery program starting out
|
||||||
|
// of the blue would be disconcerting.
|
||||||
|
if (!_silent || _launchInSilent) {
|
||||||
|
if (Thread.interrupted()) {
|
||||||
|
// One last interrupted check so we don't launch as the applet aborts
|
||||||
|
throw new InterruptedException("m.applet_stopped");
|
||||||
|
}
|
||||||
|
// And another final check for the lock. It'll already be held unless
|
||||||
|
// we're in silent mode.
|
||||||
|
_app.lockForUpdates();
|
||||||
|
launch();
|
||||||
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
log.warning("Pants! We couldn't get the job done.");
|
log.warning("Pants! We couldn't get the job done.");
|
||||||
|
|||||||
Reference in New Issue
Block a user