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>
|
||||
<artifactId>bytecodeviewer</artifactId>
|
||||
<version>2.10.14</version>
|
||||
<version>2.11.0</version>
|
||||
|
||||
<properties>
|
||||
<java.version>1.8</java.version>
|
||||
|
@ -243,6 +243,11 @@
|
|||
<artifactId>webp-imageio</artifactId>
|
||||
<version>0.2.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>de.skuzzle</groupId>
|
||||
<artifactId>semantic-version</artifactId>
|
||||
<version>2.1.0</version>
|
||||
</dependency>
|
||||
|
||||
<!-- TODO Re-add for Graal.JS support -->
|
||||
<!--<dependency>
|
||||
|
|
|
@ -45,6 +45,9 @@ public class Constants
|
|||
//dev mode is just a check for running via IDE
|
||||
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 nl = System.getProperty("line.separator");
|
||||
|
||||
|
@ -111,6 +114,9 @@ public class Constants
|
|||
*/
|
||||
public static String getVersion(String mavenVersion)
|
||||
{
|
||||
if(TEST_VERSION_CHECKER)
|
||||
return "2.10.1";
|
||||
|
||||
if(mavenVersion == null)
|
||||
{
|
||||
DEV_MODE = true;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package the.bytecode.club.bytecodeviewer.util;
|
||||
|
||||
import de.skuzzle.semantic.Version;
|
||||
import me.konloch.kontainer.io.HTTPRequest;
|
||||
import the.bytecode.club.bytecodeviewer.BytecodeViewer;
|
||||
import the.bytecode.club.bytecodeviewer.Configuration;
|
||||
|
@ -47,91 +48,118 @@ public class VersionChecker implements Runnable
|
|||
{
|
||||
try {
|
||||
HTTPRequest r = new HTTPRequest(new URL("https://raw.githubusercontent.com/Konloch/bytecode-viewer/master/VERSION"));
|
||||
final String version = r.readSingle();
|
||||
final String localVersion = VERSION + 0;
|
||||
final Version version = Version.parseVersion(r.readSingle());
|
||||
final Version localVersion = Version.parseVersion(VERSION);
|
||||
|
||||
try {
|
||||
int simplemaths = Integer.parseInt(version.replace(".", ""));
|
||||
int simplemaths2 = Integer.parseInt(localVersion.replace(".", ""));
|
||||
if (simplemaths2 > simplemaths)
|
||||
return; //developer version
|
||||
} catch (Exception ignored) {
|
||||
//developer version
|
||||
if (!localVersion.isGreaterThan(version))
|
||||
return;
|
||||
} 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",
|
||||
"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"});
|
||||
if (Desktop.isDesktopSupported())
|
||||
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(new File("./").getCanonicalFile(),
|
||||
"Select Save File",
|
||||
"Zip Archives",
|
||||
"zip");
|
||||
|
||||
int result = outdatedDialog.promptChoice();
|
||||
|
||||
if (result == 0)
|
||||
int returnVal = fc.showSaveDialog(BytecodeViewer.viewer);
|
||||
if (returnVal == JFileChooser.APPROVE_OPTION)
|
||||
{
|
||||
if (Desktop.isDesktopSupported())
|
||||
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");
|
||||
Configuration.setLastOpenDirectory(fc.getSelectedFile());
|
||||
|
||||
try {
|
||||
fc.setCurrentDirectory(new File(".").getAbsoluteFile()); //set the current working directory
|
||||
} catch (Exception e) {
|
||||
BytecodeViewer.handleException(e);
|
||||
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();
|
||||
}
|
||||
|
||||
int returnVal = fc.showSaveDialog(BytecodeViewer.viewer);
|
||||
if (returnVal == JFileChooser.APPROVE_OPTION)
|
||||
{
|
||||
Configuration.setLastOpenDirectory(fc.getSelectedFile());
|
||||
|
||||
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(() -> {
|
||||
final File finalFile = file;
|
||||
Thread downloadThread = new Thread(() -> {
|
||||
try {
|
||||
InputStream is = new URL("https://github.com/Konloch/bytecode-viewer/releases/download/v" + version + "/BytecodeViewer." + version + ".zip").openConnection().getInputStream();
|
||||
FileOutputStream fos = new FileOutputStream(finalFile);
|
||||
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);
|
||||
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];
|
||||
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)
|
||||
{
|
||||
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 (mbs % 5 == 0 && mbs != 0) {
|
||||
if (!flag)
|
||||
System.out.println("Downloaded " + mbs + "MBs so far");
|
||||
flag = true;
|
||||
|
@ -150,57 +178,19 @@ public class VersionChecker implements Runnable
|
|||
}
|
||||
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);
|
||||
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);
|
||||
} 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);
|
||||
}
|
||||
|
||||
}, "Downloader");
|
||||
downloadThread.start();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
BytecodeViewer.handleException(e);
|
||||
}
|
||||
|
||||
}, "Downloader");
|
||||
downloadThread.start();
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
|
Loading…
Reference in a new issue