only: method instead of constant

This commit is contained in:
rusefillc 2024-04-19 11:24:06 -04:00
parent ed4c6cd241
commit c5c7511ab2
3 changed files with 10 additions and 5 deletions

View File

@ -50,7 +50,7 @@ public class Autoupdate {
if (mode != UpdateMode.NEVER) {
System.out.println("Snapshot requested");
if (branchName.equals("snapshot")) {
downloadAndUnzipAutoupdate(bundleFullNameSplit, mode, ConnectionAndMeta.BASE_URL_LATEST);
downloadAndUnzipAutoupdate(bundleFullNameSplit, mode, ConnectionAndMeta.getBaseUrl());
} else {
downloadAndUnzipAutoupdate(bundleFullNameSplit, mode, String.format(ConnectionAndMeta.BASE_URL_LTS, branchName));
}

View File

@ -12,7 +12,8 @@ import java.util.Objects;
public class ConnectionAndMeta {
public static final String BASE_URL_RELEASE = "https://github.com/rusefi/rusefi/releases/latest/download/";
public static final String BASE_URL_LATEST = "https://rusefi.com/build_server/autoupdate/";
private static final String AUTOUPDATE = "/autoupdate/";
private static final String BASE_URL_LATEST = "https://rusefi.com/build_server" + AUTOUPDATE;
public static final String BASE_URL_LTS = "https://rusefi.com/build_server/lts/%s/autoupdate/";
private static final int BUFFER_SIZE = 32 * 1024;
@ -26,6 +27,10 @@ public class ConnectionAndMeta {
this.zipFileName = zipFileName;
}
public static String getBaseUrl() {
return BASE_URL_LATEST;
}
public static void downloadFile(String localTargetFileName, ConnectionAndMeta connectionAndMeta, DownloadProgressListener listener) throws IOException {
HttpURLConnection httpConnection = connectionAndMeta.getHttpConnection();
long completeFileSize = connectionAndMeta.getCompleteFileSize();

View File

@ -22,7 +22,7 @@ import static com.rusefi.ts_plugin.TsPluginLauncher.VERSION;
/**
* Download fresh copy of {@link #PLUGIN_BODY_JAR} and launch {@link #PLUGIN_ENTRY_CLASS} via reflection.
* @see ConnectionAndMeta#BASE_URL_LATEST
* @see ConnectionAndMeta#getBaseUrl
*/
public class Updater {
private static final String PLUGIN_ENTRY_CLASS = "com.rusefi.ts_plugin.PluginEntry";
@ -77,7 +77,7 @@ public class Updater {
public void run() {
ConnectionAndMeta connectionAndMeta;
try {
connectionAndMeta = new ConnectionAndMeta(PLUGIN_BODY_JAR).invoke(ConnectionAndMeta.BASE_URL_LATEST);
connectionAndMeta = new ConnectionAndMeta(PLUGIN_BODY_JAR).invoke(ConnectionAndMeta.getBaseUrl());
} catch (Exception e) {
e.printStackTrace();
return;
@ -159,7 +159,7 @@ public class Updater {
});
try {
ConnectionAndMeta connectionAndMeta = new ConnectionAndMeta(PLUGIN_BODY_JAR).invoke(ConnectionAndMeta.BASE_URL_LATEST);
ConnectionAndMeta connectionAndMeta = new ConnectionAndMeta(PLUGIN_BODY_JAR).invoke(ConnectionAndMeta.getBaseUrl());
AutoupdateUtil.downloadAutoupdateFile(LOCAL_JAR_FILE_NAME, connectionAndMeta,
TITLE);