Fixed Versioning
The downloader is still broken and seems to have issues with the entire v2.10.x line so any version prompt cannot happen till everyone is on v2.11.x or it will just be a remote error that also means the downloader needs to be fixed for v2.11.0
This commit is contained in:
parent
7056c0bd40
commit
84d3b36454
3 changed files with 116 additions and 115 deletions
7
pom.xml
7
pom.xml
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
<groupId>the.bytecode.club</groupId>
|
<groupId>the.bytecode.club</groupId>
|
||||||
<artifactId>bytecodeviewer</artifactId>
|
<artifactId>bytecodeviewer</artifactId>
|
||||||
<version>2.10.14</version>
|
<version>2.11.0</version>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<java.version>1.8</java.version>
|
<java.version>1.8</java.version>
|
||||||
|
@ -243,6 +243,11 @@
|
||||||
<artifactId>webp-imageio</artifactId>
|
<artifactId>webp-imageio</artifactId>
|
||||||
<version>0.2.1</version>
|
<version>0.2.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>de.skuzzle</groupId>
|
||||||
|
<artifactId>semantic-version</artifactId>
|
||||||
|
<version>2.1.0</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- TODO Re-add for Graal.JS support -->
|
<!-- TODO Re-add for Graal.JS support -->
|
||||||
<!--<dependency>
|
<!--<dependency>
|
||||||
|
|
|
@ -45,6 +45,9 @@ public class Constants
|
||||||
//dev mode is just a check for running via IDE
|
//dev mode is just a check for running via IDE
|
||||||
public static boolean DEV_MODE;
|
public static boolean DEV_MODE;
|
||||||
|
|
||||||
|
//if true the version checker will prompt and ask how you would like to proceed
|
||||||
|
public static final boolean TEST_VERSION_CHECKER = false;
|
||||||
|
|
||||||
public static final String fs = System.getProperty("file.separator");
|
public static final String fs = System.getProperty("file.separator");
|
||||||
public static final String nl = System.getProperty("line.separator");
|
public static final String nl = System.getProperty("line.separator");
|
||||||
|
|
||||||
|
@ -111,6 +114,9 @@ public class Constants
|
||||||
*/
|
*/
|
||||||
public static String getVersion(String mavenVersion)
|
public static String getVersion(String mavenVersion)
|
||||||
{
|
{
|
||||||
|
if(TEST_VERSION_CHECKER)
|
||||||
|
return "2.10.1";
|
||||||
|
|
||||||
if(mavenVersion == null)
|
if(mavenVersion == null)
|
||||||
{
|
{
|
||||||
DEV_MODE = true;
|
DEV_MODE = true;
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package the.bytecode.club.bytecodeviewer.util;
|
package the.bytecode.club.bytecodeviewer.util;
|
||||||
|
|
||||||
|
import de.skuzzle.semantic.Version;
|
||||||
import me.konloch.kontainer.io.HTTPRequest;
|
import me.konloch.kontainer.io.HTTPRequest;
|
||||||
import the.bytecode.club.bytecodeviewer.BytecodeViewer;
|
import the.bytecode.club.bytecodeviewer.BytecodeViewer;
|
||||||
import the.bytecode.club.bytecodeviewer.Configuration;
|
import the.bytecode.club.bytecodeviewer.Configuration;
|
||||||
|
@ -47,91 +48,118 @@ public class VersionChecker implements Runnable
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
HTTPRequest r = new HTTPRequest(new URL("https://raw.githubusercontent.com/Konloch/bytecode-viewer/master/VERSION"));
|
HTTPRequest r = new HTTPRequest(new URL("https://raw.githubusercontent.com/Konloch/bytecode-viewer/master/VERSION"));
|
||||||
final String version = r.readSingle();
|
final Version version = Version.parseVersion(r.readSingle());
|
||||||
final String localVersion = VERSION + 0;
|
final Version localVersion = Version.parseVersion(VERSION);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
int simplemaths = Integer.parseInt(version.replace(".", ""));
|
//developer version
|
||||||
int simplemaths2 = Integer.parseInt(localVersion.replace(".", ""));
|
if (!localVersion.isGreaterThan(version))
|
||||||
if (simplemaths2 > simplemaths)
|
return;
|
||||||
return; //developer version
|
} catch (Exception ignored) { }
|
||||||
} catch (Exception ignored) {
|
|
||||||
|
|
||||||
}
|
MultipleChoiceDialog outdatedDialog = new MultipleChoiceDialog("Bytecode Viewer - Outdated Version",
|
||||||
|
"Your version: " + VERSION + ", latest version: "
|
||||||
|
+ version + nl + "What would you like to do?",
|
||||||
|
new String[]{"Open The Download Page", "Download The Updated Jar", "Do Nothing (And Don't Ask Again)"});
|
||||||
|
|
||||||
if (VERSION != null && !VERSION.equals(version))
|
int result = outdatedDialog.promptChoice();
|
||||||
|
|
||||||
|
if (result == 0)
|
||||||
{
|
{
|
||||||
MultipleChoiceDialog outdatedDialog = new MultipleChoiceDialog("Bytecode Viewer - Outdated Version",
|
if (Desktop.isDesktopSupported())
|
||||||
"Your version: " + VERSION + ", latest version: "
|
Desktop.getDesktop().browse(new URI("https://github.com/Konloch/bytecode-viewer/releases"));
|
||||||
+ version + nl + "What would you like to do?",
|
else
|
||||||
new String[]{"Open The Download Page", "Download The Updated Jar", "Do Nothing"});
|
BytecodeViewer.showMessage("Cannot open the page, please manually type it."
|
||||||
|
+ nl + "https://github.com/Konloch/bytecode-viewer/releases");
|
||||||
|
}
|
||||||
|
else if (result == 1)
|
||||||
|
{
|
||||||
|
JFileChooser fc = new FileChooser(new File("./").getCanonicalFile(),
|
||||||
|
"Select Save File",
|
||||||
|
"Zip Archives",
|
||||||
|
"zip");
|
||||||
|
|
||||||
int result = outdatedDialog.promptChoice();
|
int returnVal = fc.showSaveDialog(BytecodeViewer.viewer);
|
||||||
|
if (returnVal == JFileChooser.APPROVE_OPTION)
|
||||||
if (result == 0)
|
|
||||||
{
|
{
|
||||||
if (Desktop.isDesktopSupported())
|
Configuration.setLastOpenDirectory(fc.getSelectedFile());
|
||||||
Desktop.getDesktop().browse(new URI("https://github.com/Konloch/bytecode-viewer/releases"));
|
|
||||||
else
|
|
||||||
BytecodeViewer.showMessage("Cannot open the page, please manually type it."
|
|
||||||
+ nl + "https://github.com/Konloch/bytecode-viewer/releases");
|
|
||||||
}
|
|
||||||
else if (result == 1)
|
|
||||||
{
|
|
||||||
JFileChooser fc = new FileChooser(Configuration.getLastOpenDirectory(),
|
|
||||||
"Select Save File",
|
|
||||||
"Zip Archives",
|
|
||||||
"zip");
|
|
||||||
|
|
||||||
try {
|
File file = fc.getSelectedFile();
|
||||||
fc.setCurrentDirectory(new File(".").getAbsoluteFile()); //set the current working directory
|
if (!file.getAbsolutePath().endsWith(".zip"))
|
||||||
} catch (Exception e) {
|
file = new File(file.getAbsolutePath() + ".zip");
|
||||||
BytecodeViewer.handleException(e);
|
|
||||||
|
if (file.exists())
|
||||||
|
{
|
||||||
|
MultipleChoiceDialog overwriteDialog = new MultipleChoiceDialog("Bytecode Viewer - Overwrite File",
|
||||||
|
"The file " + file + " exists, would you like to overwrite it?",
|
||||||
|
new String[]{TranslatedStrings.YES.toString(), TranslatedStrings.NO.toString()});
|
||||||
|
|
||||||
|
if (overwriteDialog.promptChoice() != 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
file.delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
int returnVal = fc.showSaveDialog(BytecodeViewer.viewer);
|
final File finalFile = file;
|
||||||
if (returnVal == JFileChooser.APPROVE_OPTION)
|
Thread downloadThread = new Thread(() -> {
|
||||||
{
|
try {
|
||||||
Configuration.setLastOpenDirectory(fc.getSelectedFile());
|
InputStream is = new URL("https://github.com/Konloch/bytecode-viewer/releases/download/v" + version + "/BytecodeViewer." + version + ".zip").openConnection().getInputStream();
|
||||||
|
FileOutputStream fos = new FileOutputStream(finalFile);
|
||||||
File file = fc.getSelectedFile();
|
|
||||||
if (!file.getAbsolutePath().endsWith(".zip"))
|
|
||||||
file = new File(file.getAbsolutePath() + ".zip");
|
|
||||||
|
|
||||||
if (file.exists())
|
|
||||||
{
|
|
||||||
MultipleChoiceDialog overwriteDialog = new MultipleChoiceDialog("Bytecode Viewer - Overwrite File",
|
|
||||||
"The file " + file + " exists, would you like to overwrite it?",
|
|
||||||
new String[]{TranslatedStrings.YES.toString(), TranslatedStrings.NO.toString()});
|
|
||||||
|
|
||||||
if (overwriteDialog.promptChoice() != 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
file.delete();
|
|
||||||
}
|
|
||||||
|
|
||||||
final File finalFile = file;
|
|
||||||
Thread downloadThread = new Thread(() -> {
|
|
||||||
try {
|
try {
|
||||||
InputStream is = new URL("https://github.com/Konloch/bytecode-viewer/releases/download/v" + version + "/BytecodeViewer." + version + ".zip").openConnection().getInputStream();
|
System.out.println("Downloading from https://github.com/Konloch/bytecode-viewer/releases/download/v" + version + "/BytecodeViewer." + version + ".zip");
|
||||||
|
byte[] buffer = new byte[8192];
|
||||||
|
int len;
|
||||||
|
int downloaded = 0;
|
||||||
|
boolean flag = false;
|
||||||
|
BytecodeViewer.showMessage("Downloading the jar in the background, when it's finished "
|
||||||
|
+ "you will be alerted with another message box." + nl + nl +
|
||||||
|
"Expect this to take several minutes.");
|
||||||
|
|
||||||
|
while ((len = is.read(buffer)) > 0)
|
||||||
|
{
|
||||||
|
fos.write(buffer, 0, len);
|
||||||
|
fos.flush();
|
||||||
|
downloaded += 8192;
|
||||||
|
int mbs = downloaded / 1048576;
|
||||||
|
if (mbs % 5 == 0 && mbs != 0)
|
||||||
|
{
|
||||||
|
if (!flag)
|
||||||
|
System.out.println("Downloaded " + mbs + "MBs so far");
|
||||||
|
flag = true;
|
||||||
|
} else
|
||||||
|
flag = false;
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
try {
|
||||||
|
if (is != null) {
|
||||||
|
is.close();
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
fos.flush();
|
||||||
|
fos.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
System.out.println("Download finished!");
|
||||||
|
BytecodeViewer.showMessage("Download successful! You can find the updated program at " + finalFile.getAbsolutePath());
|
||||||
|
} catch (FileNotFoundException e) {
|
||||||
|
try {
|
||||||
|
InputStream is = new URL("https://github.com/Konloch/bytecode-viewer/releases/download/v" + version + "/BytecodeViewer." + version + ".jar"
|
||||||
|
).openConnection().getInputStream();
|
||||||
FileOutputStream fos = new FileOutputStream(finalFile);
|
FileOutputStream fos = new FileOutputStream(finalFile);
|
||||||
try {
|
try {
|
||||||
System.out.println("Downloading from https://github.com/Konloch/bytecode-viewer/releases/download/v" + version + "/BytecodeViewer." + version + ".zip");
|
System.out.println("Downloading from https://github.com/Konloch/bytecode-viewer/releases/download/v" + version + "/BytecodeViewer." + version + ".jar");
|
||||||
byte[] buffer = new byte[8192];
|
byte[] buffer = new byte[8192];
|
||||||
int len;
|
int len;
|
||||||
int downloaded = 0;
|
int downloaded = 0;
|
||||||
boolean flag = false;
|
boolean flag = false;
|
||||||
BytecodeViewer.showMessage("Downloading the jar in the background, when it's finished "
|
BytecodeViewer.showMessage("Downloading the jar in the background, when it's "
|
||||||
+ "you will be alerted with another message box." + nl + nl +
|
+ "finished you will be alerted with another message box." + nl + nl + "Expect this to take several minutes.");
|
||||||
"Expect this to take several minutes.");
|
while ((len = is.read(buffer)) > 0) {
|
||||||
|
|
||||||
while ((len = is.read(buffer)) > 0)
|
|
||||||
{
|
|
||||||
fos.write(buffer, 0, len);
|
fos.write(buffer, 0, len);
|
||||||
fos.flush();
|
fos.flush();
|
||||||
downloaded += 8192;
|
downloaded += 8192;
|
||||||
int mbs = downloaded / 1048576;
|
int mbs = downloaded / 1048576;
|
||||||
if (mbs % 5 == 0 && mbs != 0)
|
if (mbs % 5 == 0 && mbs != 0) {
|
||||||
{
|
|
||||||
if (!flag)
|
if (!flag)
|
||||||
System.out.println("Downloaded " + mbs + "MBs so far");
|
System.out.println("Downloaded " + mbs + "MBs so far");
|
||||||
flag = true;
|
flag = true;
|
||||||
|
@ -150,57 +178,19 @@ public class VersionChecker implements Runnable
|
||||||
}
|
}
|
||||||
System.out.println("Download finished!");
|
System.out.println("Download finished!");
|
||||||
BytecodeViewer.showMessage("Download successful! You can find the updated program at " + finalFile.getAbsolutePath());
|
BytecodeViewer.showMessage("Download successful! You can find the updated program at " + finalFile.getAbsolutePath());
|
||||||
} catch (FileNotFoundException e) {
|
} catch (FileNotFoundException ex) {
|
||||||
try {
|
BytecodeViewer.showMessage("Unable to download, the zip file has not been uploaded yet, "
|
||||||
InputStream is = new URL("https://github.com/Konloch/bytecode-viewer/releases/download/v" + version + "/BytecodeViewer." + version + ".jar"
|
+ "please try again in about 10 minutes.");
|
||||||
).openConnection().getInputStream();
|
} catch (Exception ex) {
|
||||||
FileOutputStream fos = new FileOutputStream(finalFile);
|
BytecodeViewer.handleException(ex);
|
||||||
try {
|
|
||||||
System.out.println("Downloading from https://github.com/Konloch/bytecode-viewer/releases/download/v" + version + "/BytecodeViewer." + version + ".jar");
|
|
||||||
byte[] buffer = new byte[8192];
|
|
||||||
int len;
|
|
||||||
int downloaded = 0;
|
|
||||||
boolean flag = false;
|
|
||||||
BytecodeViewer.showMessage("Downloading the jar in the background, when it's "
|
|
||||||
+ "finished you will be alerted with another message box." + nl + nl + "Expect this to take several minutes.");
|
|
||||||
while ((len = is.read(buffer)) > 0) {
|
|
||||||
fos.write(buffer, 0, len);
|
|
||||||
fos.flush();
|
|
||||||
downloaded += 8192;
|
|
||||||
int mbs = downloaded / 1048576;
|
|
||||||
if (mbs % 5 == 0 && mbs != 0) {
|
|
||||||
if (!flag)
|
|
||||||
System.out.println("Downloaded " + mbs + "MBs so far");
|
|
||||||
flag = true;
|
|
||||||
} else
|
|
||||||
flag = false;
|
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
try {
|
|
||||||
if (is != null) {
|
|
||||||
is.close();
|
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
fos.flush();
|
|
||||||
fos.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
System.out.println("Download finished!");
|
|
||||||
BytecodeViewer.showMessage("Download successful! You can find the updated program at " + finalFile.getAbsolutePath());
|
|
||||||
} catch (FileNotFoundException ex) {
|
|
||||||
BytecodeViewer.showMessage("Unable to download, the zip file has not been uploaded yet, "
|
|
||||||
+ "please try again in about 10 minutes.");
|
|
||||||
} catch (Exception ex) {
|
|
||||||
BytecodeViewer.handleException(ex);
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
|
||||||
BytecodeViewer.handleException(e);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}, "Downloader");
|
} catch (Exception e) {
|
||||||
downloadThread.start();
|
BytecodeViewer.handleException(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}, "Downloader");
|
||||||
|
downloadThread.start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
Loading…
Reference in a new issue