Install the local JVM resource before unpacking.

Fixes #78.
This commit is contained in:
Michael Bayne
2017-02-12 09:20:42 -08:00
parent 0b5c82a116
commit e60b95cf2d
2 changed files with 13 additions and 5 deletions
@@ -246,6 +246,17 @@ public class Resource
}
}
/**
* Installs the {@code getLocalNew} version of this resource to {@code getLocal}.
*/
public void install () throws IOException {
File source = getLocalNew(), dest = getLocal();
log.info("- " + source);
if (!FileUtil.renameTo(source, dest)) {
throw new IOException("Failed to rename " + source + " to " + dest);
}
}
/**
* Unpacks this resource file into the directory that contains it. Returns
* false if an error occurs while unpacking it.
@@ -144,11 +144,7 @@ public abstract class Getdown extends Thread
if (_readyToInstall) {
log.info("Installing downloaded resources:");
for (Resource resource : _toBeInstalledResouces) {
File source = resource.getLocalNew(), dest = resource.getLocal();
log.info("- " + source);
if (!FileUtil.renameTo(source, dest)) {
throw new IOException("Failed to rename " + source + " to " + dest);
}
resource.install();
if (Thread.interrupted()) {
throw new InterruptedException("m.applet_stopped");
}
@@ -642,6 +638,7 @@ public abstract class Getdown extends Thread
reportTrackingEvent("jvm_unpack", -1);
updateStatus("m.unpacking_java");
vmjar.install();
if (!vmjar.unpack()) {
throw new IOException("m.java_unpack_failed");
}