1
0
mirror of https://github.com/SKCraft/Launcher.git synced 2024-11-27 12:46:22 +01:00

Allow bootstrap server to announce unpacked update jars

Pack200 is dead, this is the start of its removal
This commit is contained in:
Henry Le Grys 2021-02-02 03:18:22 +00:00
parent 27da4e8e4c
commit 662162392e

View File

@ -61,11 +61,10 @@ public class Downloader implements Runnable, ProgressObservable {
}
});
File finalFile = new File(bootstrap.getBinariesDir(), System.currentTimeMillis() + ".jar.pack");
File tempFile = new File(finalFile.getParentFile(), finalFile.getName() + ".tmp");
URL updateUrl = HttpRequest.url(bootstrap.getProperties().getProperty("latestUrl"));
log.info("Reading update URL " + updateUrl + "...");
List<LauncherBinary> binaries = new ArrayList<LauncherBinary>();
try {
String data = HttpRequest
@ -93,6 +92,16 @@ public class Downloader implements Runnable, ProgressObservable {
checkInterrupted();
boolean packed = true;
Object packedCheck = ((JSONObject) object).get("packed");
if (packedCheck == Boolean.FALSE) {
packed = false;
}
String extension = packed ? ".jar.pack" : ".jar";
File finalFile = new File(bootstrap.getBinariesDir(), System.currentTimeMillis() + extension);
File tempFile = new File(finalFile.getParentFile(), finalFile.getName() + ".tmp");
log.info("Downloading " + url + " to " + tempFile.getAbsolutePath());
httpRequest = HttpRequest.get(url);
@ -103,6 +112,9 @@ public class Downloader implements Runnable, ProgressObservable {
finalFile.delete();
tempFile.renameTo(finalFile);
LauncherBinary binary = new LauncherBinary(finalFile);
binaries.add(binary);
} finally {
SwingUtilities.invokeLater(new Runnable() {
@Override
@ -113,9 +125,6 @@ public class Downloader implements Runnable, ProgressObservable {
});
}
LauncherBinary binary = new LauncherBinary(finalFile);
List<LauncherBinary> binaries = new ArrayList<LauncherBinary>();
binaries.add(binary);
bootstrap.launchExisting(binaries, false);
}