From e68c68a2b6b6766c8b123a62b1a5523af2140372 Mon Sep 17 00:00:00 2001 From: rusefi Date: Wed, 17 Jun 2020 16:50:14 -0400 Subject: [PATCH] TS plugin --- .../src/com/rusefi/autoupdate/AutoupdateUtil.java | 4 ++-- java_tools/ts_plugin_launcher/build.xml | 1 + .../src/com/rusefi/ts_plugin/Updater.java | 9 ++++++--- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/java_console/autoupdate/src/com/rusefi/autoupdate/AutoupdateUtil.java b/java_console/autoupdate/src/com/rusefi/autoupdate/AutoupdateUtil.java index a2b2897f55..6820a165aa 100644 --- a/java_console/autoupdate/src/com/rusefi/autoupdate/AutoupdateUtil.java +++ b/java_console/autoupdate/src/com/rusefi/autoupdate/AutoupdateUtil.java @@ -19,10 +19,10 @@ public class AutoupdateUtil { private static final int BUFFER_SIZE = 32 * 1024; private static final int STEPS = 1000; - public static void downloadAutoupdateFile(String zipFileName, HttpURLConnection httpConnection, long completeFileSize, String title) throws IOException { + public static void downloadAutoupdateFile(String localZipFileName, HttpURLConnection httpConnection, long completeFileSize, String title) throws IOException { Objects.requireNonNull(httpConnection, "httpConnection"); BufferedInputStream in = new BufferedInputStream(httpConnection.getInputStream()); - FileOutputStream fos = new FileOutputStream(zipFileName); + FileOutputStream fos = new FileOutputStream(localZipFileName); BufferedOutputStream bout = new BufferedOutputStream(fos, BUFFER_SIZE); byte[] data = new byte[BUFFER_SIZE]; long downloadedFileSize = 0; diff --git a/java_tools/ts_plugin_launcher/build.xml b/java_tools/ts_plugin_launcher/build.xml index 89a8f8ac77..16f65b82da 100644 --- a/java_tools/ts_plugin_launcher/build.xml +++ b/java_tools/ts_plugin_launcher/build.xml @@ -14,6 +14,7 @@ destdir="build/classes" classpath="${console_path}/lib/junit.jar:${console_path}/lib/annotations.jar:lib/TunerStudioPluginAPI.jar:${console_path}/lib/httpclient.jar:${console_path}/lib/httpmime.jar:${console_path}/lib/httpcore.jar" > + diff --git a/java_tools/ts_plugin_launcher/src/com/rusefi/ts_plugin/Updater.java b/java_tools/ts_plugin_launcher/src/com/rusefi/ts_plugin/Updater.java index a5cb14cc70..c652daae84 100644 --- a/java_tools/ts_plugin_launcher/src/com/rusefi/ts_plugin/Updater.java +++ b/java_tools/ts_plugin_launcher/src/com/rusefi/ts_plugin/Updater.java @@ -1,6 +1,7 @@ package com.rusefi.ts_plugin; import com.rusefi.autoupdate.AutoupdateUtil; +import com.rusefi.ui.storage.PersistentConfiguration; import org.putgemin.VerticalFlowLayout; import javax.swing.*; @@ -16,6 +17,7 @@ import static com.rusefi.ts_plugin.TsPluginLauncher.VERSION; public class Updater { private static final String PLUGIN_BODY_JAR = "rusefi_plugin_body.jar"; + public static final String LOCAL_JAR_FILE_NAME = PersistentConfiguration.RUSEFI_SETTINGS_FOLDER + File.separator + PLUGIN_BODY_JAR; private static final String TITLE = "rusEFI plugin installer " + VERSION; private final JPanel content = new JPanel(new VerticalFlowLayout()); @@ -24,7 +26,7 @@ public class Updater { content.add(new JLabel("" + VERSION)); String version = null; - if (new File(PLUGIN_BODY_JAR).exists()) { + if (new File(LOCAL_JAR_FILE_NAME).exists()) { version = getVersion(); } @@ -76,12 +78,13 @@ public class Updater { try { AutoupdateUtil.ConnectionAndMeta connectionAndMeta = new AutoupdateUtil.ConnectionAndMeta(PLUGIN_BODY_JAR).invoke(); - AutoupdateUtil.downloadAutoupdateFile(PLUGIN_BODY_JAR, connectionAndMeta.getHttpConnection(), connectionAndMeta.getCompleteFileSize(), + AutoupdateUtil.downloadAutoupdateFile(LOCAL_JAR_FILE_NAME, connectionAndMeta.getHttpConnection(), connectionAndMeta.getCompleteFileSize(), TITLE); startPlugin(); } catch (IOException | ClassNotFoundException | InstantiationException | IllegalAccessException e) { + e.printStackTrace(); download.setEnabled(true); } } @@ -98,7 +101,7 @@ public class Updater { } private static Class getPluginClass() throws MalformedURLException, ClassNotFoundException { - URLClassLoader jarClassLoader = AutoupdateUtil.getClassLoaderByJar(PLUGIN_BODY_JAR); + URLClassLoader jarClassLoader = AutoupdateUtil.getClassLoaderByJar(LOCAL_JAR_FILE_NAME); return Class.forName("com.rusefi.ts_plugin.PluginEntry", true, jarClassLoader); }