fix ArrayOutOfBoundsException & shows "task aborted".
This commit is contained in:
@@ -1331,7 +1331,6 @@ org.jackhuang.hellominecraft.launcher.launch.LibraryDownloadTask -> org.jackhuan
|
|||||||
java.io.InputStream stream -> a
|
java.io.InputStream stream -> a
|
||||||
java.io.RandomAccessFile file -> a
|
java.io.RandomAccessFile file -> a
|
||||||
boolean shouldContinue -> a
|
boolean shouldContinue -> a
|
||||||
boolean aborted -> b
|
|
||||||
int size -> a
|
int size -> a
|
||||||
56:76:boolean executeTask() -> a
|
56:76:boolean executeTask() -> a
|
||||||
86:167:boolean download(java.net.URL,java.io.File) -> a
|
86:167:boolean download(java.net.URL,java.io.File) -> a
|
||||||
@@ -3232,24 +3231,26 @@ org.jackhuang.hellominecraft.tasks.ProgressProviderListener -> org.jackhuang.hel
|
|||||||
void setStatus(org.jackhuang.hellominecraft.tasks.Task,java.lang.String) -> a
|
void setStatus(org.jackhuang.hellominecraft.tasks.Task,java.lang.String) -> a
|
||||||
void onProgressProviderDone(org.jackhuang.hellominecraft.tasks.Task) -> a
|
void onProgressProviderDone(org.jackhuang.hellominecraft.tasks.Task) -> a
|
||||||
org.jackhuang.hellominecraft.tasks.Task -> org.jackhuang.hellominecraft.launcher.dj:
|
org.jackhuang.hellominecraft.tasks.Task -> org.jackhuang.hellominecraft.launcher.dj:
|
||||||
|
boolean aborted -> b
|
||||||
java.lang.Throwable failReason -> a
|
java.lang.Throwable failReason -> a
|
||||||
java.lang.String tag -> c
|
java.lang.String tag -> c
|
||||||
boolean parallelExecuting -> c
|
boolean parallelExecuting -> c
|
||||||
java.util.ArrayList taskListener -> b
|
java.util.ArrayList taskListener -> b
|
||||||
org.jackhuang.hellominecraft.tasks.ProgressProviderListener ppl -> a
|
org.jackhuang.hellominecraft.tasks.ProgressProviderListener ppl -> a
|
||||||
boolean executeTask() -> a
|
boolean executeTask() -> a
|
||||||
42:42:boolean abort() -> b
|
42:43:boolean abort() -> b
|
||||||
46:46:java.lang.Throwable getFailReason() -> a
|
49:49:boolean isAborted() -> c
|
||||||
51:52:void setFailReason(java.lang.Throwable) -> a
|
53:53:java.lang.Throwable getFailReason() -> a
|
||||||
58:59:org.jackhuang.hellominecraft.tasks.Task setTag(java.lang.String) -> a
|
58:59:void setFailReason(java.lang.Throwable) -> a
|
||||||
63:63:boolean isParallelExecuting() -> c
|
65:66:org.jackhuang.hellominecraft.tasks.Task setTag(java.lang.String) -> a
|
||||||
67:68:void setParallelExecuting(boolean) -> a
|
70:70:boolean isParallelExecuting() -> d
|
||||||
73:74:org.jackhuang.hellominecraft.tasks.Task addTaskListener(org.jackhuang.hellominecraft.tasks.DoingDoneListener) -> a
|
74:75:void setParallelExecuting(boolean) -> a
|
||||||
78:78:java.util.ArrayList getTaskListeners() -> a
|
80:81:org.jackhuang.hellominecraft.tasks.Task addTaskListener(org.jackhuang.hellominecraft.tasks.DoingDoneListener) -> a
|
||||||
|
85:85:java.util.ArrayList getTaskListeners() -> a
|
||||||
java.lang.String getInfo() -> a
|
java.lang.String getInfo() -> a
|
||||||
84:84:java.util.Collection getDependTasks() -> b
|
91:91:java.util.Collection getDependTasks() -> b
|
||||||
88:88:java.util.Collection getAfterTasks() -> a
|
95:95:java.util.Collection getAfterTasks() -> a
|
||||||
94:95:org.jackhuang.hellominecraft.tasks.Task setProgressProviderListener(org.jackhuang.hellominecraft.tasks.ProgressProviderListener) -> a
|
101:102:org.jackhuang.hellominecraft.tasks.Task setProgressProviderListener(org.jackhuang.hellominecraft.tasks.ProgressProviderListener) -> a
|
||||||
org.jackhuang.hellominecraft.tasks.TaskInfo -> org.jackhuang.hellominecraft.launcher.dk:
|
org.jackhuang.hellominecraft.tasks.TaskInfo -> org.jackhuang.hellominecraft.launcher.dk:
|
||||||
java.lang.String info -> a
|
java.lang.String info -> a
|
||||||
33:33:java.lang.String getInfo() -> a
|
33:33:java.lang.String getInfo() -> a
|
||||||
@@ -3311,14 +3312,14 @@ org.jackhuang.hellominecraft.tasks.TaskWindow -> org.jackhuang.hellominecraft.la
|
|||||||
235:243:void onDoing(org.jackhuang.hellominecraft.tasks.Task) -> b
|
235:243:void onDoing(org.jackhuang.hellominecraft.tasks.Task) -> b
|
||||||
246:246:boolean areTasksFinished() -> b
|
246:246:boolean areTasksFinished() -> b
|
||||||
251:260:void onDone(org.jackhuang.hellominecraft.tasks.Task) -> c
|
251:260:void onDone(org.jackhuang.hellominecraft.tasks.Task) -> c
|
||||||
264:273:void onFailed(org.jackhuang.hellominecraft.tasks.Task) -> d
|
264:274:void onFailed(org.jackhuang.hellominecraft.tasks.Task) -> d
|
||||||
278:278:void onProgressProviderDone(org.jackhuang.hellominecraft.tasks.Task) -> a
|
279:279:void onProgressProviderDone(org.jackhuang.hellominecraft.tasks.Task) -> a
|
||||||
282:285:void setStatus(org.jackhuang.hellominecraft.tasks.Task,java.lang.String) -> a
|
283:286:void setStatus(org.jackhuang.hellominecraft.tasks.Task,java.lang.String) -> a
|
||||||
33:33:void onFailed(java.lang.Object) -> c
|
33:33:void onFailed(java.lang.Object) -> c
|
||||||
33:33:void onDoing(java.lang.Object) -> b
|
33:33:void onDoing(java.lang.Object) -> b
|
||||||
33:33:void onDone(java.lang.Object) -> a
|
33:33:void onDone(java.lang.Object) -> a
|
||||||
283:284:void lambda$setStatus$4(java.lang.String) -> a
|
284:285:void lambda$setStatus$4(java.lang.String) -> a
|
||||||
265:272:void lambda$onFailed$3(org.jackhuang.hellominecraft.tasks.Task) -> e
|
265:273:void lambda$onFailed$3(org.jackhuang.hellominecraft.tasks.Task) -> e
|
||||||
252:259:void lambda$onDone$2(org.jackhuang.hellominecraft.tasks.Task) -> f
|
252:259:void lambda$onDone$2(org.jackhuang.hellominecraft.tasks.Task) -> f
|
||||||
238:242:void lambda$onDoing$1(org.jackhuang.hellominecraft.tasks.Task) -> g
|
238:242:void lambda$onDoing$1(org.jackhuang.hellominecraft.tasks.Task) -> g
|
||||||
213:223:void lambda$setProgress$0(org.jackhuang.hellominecraft.tasks.Task,int,int) -> b
|
213:223:void lambda$setProgress$0(org.jackhuang.hellominecraft.tasks.Task,int,int) -> b
|
||||||
@@ -3334,7 +3335,7 @@ org.jackhuang.hellominecraft.tasks.TaskWindow$$Lambda$1 -> org.jackhuang.hellomi
|
|||||||
java.lang.Runnable get$Lambda(org.jackhuang.hellominecraft.tasks.TaskList) -> b
|
java.lang.Runnable get$Lambda(org.jackhuang.hellominecraft.tasks.TaskList) -> b
|
||||||
void run() -> run
|
void run() -> run
|
||||||
java.lang.Runnable lambdaFactory$(org.jackhuang.hellominecraft.tasks.TaskList) -> a
|
java.lang.Runnable lambdaFactory$(org.jackhuang.hellominecraft.tasks.TaskList) -> a
|
||||||
org.jackhuang.hellominecraft.tasks.TaskWindow$$Lambda$4 -> org.jackhuang.hellominecraft.launcher.dr:
|
org.jackhuang.hellominecraft.tasks.TaskWindow$$Lambda$2 -> org.jackhuang.hellominecraft.launcher.dr:
|
||||||
org.jackhuang.hellominecraft.tasks.TaskWindow arg$1 -> a
|
org.jackhuang.hellominecraft.tasks.TaskWindow arg$1 -> a
|
||||||
org.jackhuang.hellominecraft.tasks.Task arg$2 -> a
|
org.jackhuang.hellominecraft.tasks.Task arg$2 -> a
|
||||||
int arg$3 -> a
|
int arg$3 -> a
|
||||||
@@ -3342,25 +3343,25 @@ org.jackhuang.hellominecraft.tasks.TaskWindow$$Lambda$4 -> org.jackhuang.hellomi
|
|||||||
java.lang.Runnable get$Lambda(org.jackhuang.hellominecraft.tasks.TaskWindow,org.jackhuang.hellominecraft.tasks.Task,int,int) -> b
|
java.lang.Runnable get$Lambda(org.jackhuang.hellominecraft.tasks.TaskWindow,org.jackhuang.hellominecraft.tasks.Task,int,int) -> b
|
||||||
void run() -> run
|
void run() -> run
|
||||||
java.lang.Runnable lambdaFactory$(org.jackhuang.hellominecraft.tasks.TaskWindow,org.jackhuang.hellominecraft.tasks.Task,int,int) -> a
|
java.lang.Runnable lambdaFactory$(org.jackhuang.hellominecraft.tasks.TaskWindow,org.jackhuang.hellominecraft.tasks.Task,int,int) -> a
|
||||||
org.jackhuang.hellominecraft.tasks.TaskWindow$$Lambda$5 -> org.jackhuang.hellominecraft.launcher.ds:
|
org.jackhuang.hellominecraft.tasks.TaskWindow$$Lambda$3 -> org.jackhuang.hellominecraft.launcher.ds:
|
||||||
org.jackhuang.hellominecraft.tasks.TaskWindow arg$1 -> a
|
org.jackhuang.hellominecraft.tasks.TaskWindow arg$1 -> a
|
||||||
org.jackhuang.hellominecraft.tasks.Task arg$2 -> a
|
org.jackhuang.hellominecraft.tasks.Task arg$2 -> a
|
||||||
java.lang.Runnable get$Lambda(org.jackhuang.hellominecraft.tasks.TaskWindow,org.jackhuang.hellominecraft.tasks.Task) -> b
|
java.lang.Runnable get$Lambda(org.jackhuang.hellominecraft.tasks.TaskWindow,org.jackhuang.hellominecraft.tasks.Task) -> b
|
||||||
void run() -> run
|
void run() -> run
|
||||||
java.lang.Runnable lambdaFactory$(org.jackhuang.hellominecraft.tasks.TaskWindow,org.jackhuang.hellominecraft.tasks.Task) -> a
|
java.lang.Runnable lambdaFactory$(org.jackhuang.hellominecraft.tasks.TaskWindow,org.jackhuang.hellominecraft.tasks.Task) -> a
|
||||||
org.jackhuang.hellominecraft.tasks.TaskWindow$$Lambda$6 -> org.jackhuang.hellominecraft.launcher.dt:
|
org.jackhuang.hellominecraft.tasks.TaskWindow$$Lambda$4 -> org.jackhuang.hellominecraft.launcher.dt:
|
||||||
org.jackhuang.hellominecraft.tasks.TaskWindow arg$1 -> a
|
org.jackhuang.hellominecraft.tasks.TaskWindow arg$1 -> a
|
||||||
org.jackhuang.hellominecraft.tasks.Task arg$2 -> a
|
org.jackhuang.hellominecraft.tasks.Task arg$2 -> a
|
||||||
java.lang.Runnable get$Lambda(org.jackhuang.hellominecraft.tasks.TaskWindow,org.jackhuang.hellominecraft.tasks.Task) -> b
|
java.lang.Runnable get$Lambda(org.jackhuang.hellominecraft.tasks.TaskWindow,org.jackhuang.hellominecraft.tasks.Task) -> b
|
||||||
void run() -> run
|
void run() -> run
|
||||||
java.lang.Runnable lambdaFactory$(org.jackhuang.hellominecraft.tasks.TaskWindow,org.jackhuang.hellominecraft.tasks.Task) -> a
|
java.lang.Runnable lambdaFactory$(org.jackhuang.hellominecraft.tasks.TaskWindow,org.jackhuang.hellominecraft.tasks.Task) -> a
|
||||||
org.jackhuang.hellominecraft.tasks.TaskWindow$$Lambda$7 -> org.jackhuang.hellominecraft.launcher.du:
|
org.jackhuang.hellominecraft.tasks.TaskWindow$$Lambda$5 -> org.jackhuang.hellominecraft.launcher.du:
|
||||||
org.jackhuang.hellominecraft.tasks.TaskWindow arg$1 -> a
|
org.jackhuang.hellominecraft.tasks.TaskWindow arg$1 -> a
|
||||||
org.jackhuang.hellominecraft.tasks.Task arg$2 -> a
|
org.jackhuang.hellominecraft.tasks.Task arg$2 -> a
|
||||||
java.lang.Runnable get$Lambda(org.jackhuang.hellominecraft.tasks.TaskWindow,org.jackhuang.hellominecraft.tasks.Task) -> b
|
java.lang.Runnable get$Lambda(org.jackhuang.hellominecraft.tasks.TaskWindow,org.jackhuang.hellominecraft.tasks.Task) -> b
|
||||||
void run() -> run
|
void run() -> run
|
||||||
java.lang.Runnable lambdaFactory$(org.jackhuang.hellominecraft.tasks.TaskWindow,org.jackhuang.hellominecraft.tasks.Task) -> a
|
java.lang.Runnable lambdaFactory$(org.jackhuang.hellominecraft.tasks.TaskWindow,org.jackhuang.hellominecraft.tasks.Task) -> a
|
||||||
org.jackhuang.hellominecraft.tasks.TaskWindow$$Lambda$8 -> org.jackhuang.hellominecraft.launcher.dv:
|
org.jackhuang.hellominecraft.tasks.TaskWindow$$Lambda$6 -> org.jackhuang.hellominecraft.launcher.dv:
|
||||||
org.jackhuang.hellominecraft.tasks.TaskWindow arg$1 -> a
|
org.jackhuang.hellominecraft.tasks.TaskWindow arg$1 -> a
|
||||||
java.lang.String arg$2 -> a
|
java.lang.String arg$2 -> a
|
||||||
java.lang.Runnable get$Lambda(org.jackhuang.hellominecraft.tasks.TaskWindow,java.lang.String) -> b
|
java.lang.Runnable get$Lambda(org.jackhuang.hellominecraft.tasks.TaskWindow,java.lang.String) -> b
|
||||||
@@ -3399,7 +3400,6 @@ org.jackhuang.hellominecraft.tasks.download.FileDownloadTask -> org.jackhuang.he
|
|||||||
java.io.RandomAccessFile file -> a
|
java.io.RandomAccessFile file -> a
|
||||||
java.io.InputStream stream -> a
|
java.io.InputStream stream -> a
|
||||||
boolean shouldContinue -> a
|
boolean shouldContinue -> a
|
||||||
boolean aborted -> b
|
|
||||||
java.util.ArrayList al -> a
|
java.util.ArrayList al -> a
|
||||||
103:103:java.lang.String getUrl() -> b
|
103:103:java.lang.String getUrl() -> b
|
||||||
112:128:void closeFiles() -> a
|
112:128:void closeFiles() -> a
|
||||||
@@ -3427,9 +3427,9 @@ org.jackhuang.hellominecraft.tasks.download.HTTPGetTask -> org.jackhuang.hellomi
|
|||||||
org.jackhuang.hellominecraft.utils.EventHandler tdtsl -> a
|
org.jackhuang.hellominecraft.utils.EventHandler tdtsl -> a
|
||||||
boolean shouldContinue -> a
|
boolean shouldContinue -> a
|
||||||
54:78:boolean executeTask() -> a
|
54:78:boolean executeTask() -> a
|
||||||
83:84:boolean abort() -> b
|
83:85:boolean abort() -> b
|
||||||
89:89:java.lang.String getInfo() -> a
|
90:90:java.lang.String getInfo() -> a
|
||||||
94:94:java.lang.String getResult() -> b
|
95:95:java.lang.String getResult() -> b
|
||||||
32:32:java.lang.Object getResult() -> a
|
32:32:java.lang.Object getResult() -> a
|
||||||
org.jackhuang.hellominecraft.tasks.download.NetException -> org.jackhuang.hellominecraft.launcher.dH:
|
org.jackhuang.hellominecraft.tasks.download.NetException -> org.jackhuang.hellominecraft.launcher.dH:
|
||||||
org.jackhuang.hellominecraft.utils.ArrayUtils -> org.jackhuang.hellominecraft.launcher.dI:
|
org.jackhuang.hellominecraft.utils.ArrayUtils -> org.jackhuang.hellominecraft.launcher.dI:
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ public class LibraryDownloadTask extends Task {
|
|||||||
|
|
||||||
InputStream stream;
|
InputStream stream;
|
||||||
RandomAccessFile file;
|
RandomAccessFile file;
|
||||||
boolean shouldContinue = true, aborted = false;
|
boolean shouldContinue = true;
|
||||||
int size = -1;
|
int size = -1;
|
||||||
|
|
||||||
boolean download(URL url, File filePath) {
|
boolean download(URL url, File filePath) {
|
||||||
|
|||||||
@@ -39,8 +39,15 @@ public abstract class Task {
|
|||||||
* @return is aborted.
|
* @return is aborted.
|
||||||
*/
|
*/
|
||||||
public boolean abort() {
|
public boolean abort() {
|
||||||
|
aborted = true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected boolean aborted = false;
|
||||||
|
|
||||||
|
public boolean isAborted() {
|
||||||
|
return aborted;
|
||||||
|
}
|
||||||
|
|
||||||
public Throwable getFailReason() {
|
public Throwable getFailReason() {
|
||||||
return failReason;
|
return failReason;
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ public class TaskList extends Thread {
|
|||||||
ArrayList<NonConsumer> allDone = new ArrayList();
|
ArrayList<NonConsumer> allDone = new ArrayList();
|
||||||
ArrayList<DoingDoneListener<Task>> taskListener = new ArrayList();
|
ArrayList<DoingDoneListener<Task>> taskListener = new ArrayList();
|
||||||
|
|
||||||
int totTask = 0;
|
int totTask;
|
||||||
boolean shouldContinue = true;
|
boolean shouldContinue = true;
|
||||||
|
|
||||||
public TaskList() {
|
public TaskList() {
|
||||||
@@ -43,7 +43,6 @@ public class TaskList extends Thread {
|
|||||||
|
|
||||||
public void clean() {
|
public void clean() {
|
||||||
shouldContinue = true;
|
shouldContinue = true;
|
||||||
totTask = 0;
|
|
||||||
taskQueue.clear();
|
taskQueue.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -57,7 +56,6 @@ public class TaskList extends Thread {
|
|||||||
|
|
||||||
public void addTask(Task task) {
|
public void addTask(Task task) {
|
||||||
taskQueue.add(task);
|
taskQueue.add(task);
|
||||||
totTask++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int taskCount() {
|
public int taskCount() {
|
||||||
@@ -120,7 +118,7 @@ public class TaskList extends Thread {
|
|||||||
d.onDoing(t);
|
d.onDoing(t);
|
||||||
|
|
||||||
if (t.executeTask()) {
|
if (t.executeTask()) {
|
||||||
HMCLog.log("Task finished: " + t.getInfo());
|
HMCLog.log((t.isAborted() ? "Task aborted: " : "Task finished: ") + t.getInfo());
|
||||||
for (DoingDoneListener<Task> d : taskListener)
|
for (DoingDoneListener<Task> d : taskListener)
|
||||||
d.onDone(t);
|
d.onDone(t);
|
||||||
for (DoingDoneListener<Task> d : t.getTaskListeners())
|
for (DoingDoneListener<Task> d : t.getTaskListeners())
|
||||||
@@ -140,6 +138,7 @@ public class TaskList extends Thread {
|
|||||||
Thread.currentThread().setName("TaskList");
|
Thread.currentThread().setName("TaskList");
|
||||||
|
|
||||||
threadPool.clear();
|
threadPool.clear();
|
||||||
|
totTask = taskQueue.size();
|
||||||
for (Task taskQueue1 : taskQueue)
|
for (Task taskQueue1 : taskQueue)
|
||||||
executeTask(taskQueue1);
|
executeTask(taskQueue1);
|
||||||
if (shouldContinue)
|
if (shouldContinue)
|
||||||
|
|||||||
@@ -182,7 +182,7 @@ public class TaskWindow extends javax.swing.JDialog
|
|||||||
|
|
||||||
private void formWindowClosed(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosed
|
private void formWindowClosed(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosed
|
||||||
tasks.clear();
|
tasks.clear();
|
||||||
|
|
||||||
if (!this.failReasons.isEmpty()) {
|
if (!this.failReasons.isEmpty()) {
|
||||||
MessageBox.Show(StrUtils.parseParams("", failReasons.toArray(), "\n"), C.i18n("message.error"), MessageBox.ERROR_MESSAGE);
|
MessageBox.Show(StrUtils.parseParams("", failReasons.toArray(), "\n"), C.i18n("message.error"), MessageBox.ERROR_MESSAGE);
|
||||||
failReasons.clear();
|
failReasons.clear();
|
||||||
@@ -206,18 +206,18 @@ public class TaskWindow extends javax.swing.JDialog
|
|||||||
|
|
||||||
ArrayList<Task> tasks = new ArrayList<>();
|
ArrayList<Task> tasks = new ArrayList<>();
|
||||||
ArrayList<Integer> progresses = new ArrayList<>();
|
ArrayList<Integer> progresses = new ArrayList<>();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setProgress(Task task, int progress, int max) {
|
public void setProgress(Task task, int progress, int max) {
|
||||||
SwingUtilities.invokeLater(() -> {
|
SwingUtilities.invokeLater(() -> {
|
||||||
int idx = tasks.indexOf(task);
|
int idx = tasks.indexOf(task);
|
||||||
if(idx == -1) return;
|
if (idx == -1) return;
|
||||||
int pgs = progress * 100 / max;
|
int pgs = progress * 100 / max;
|
||||||
if(progresses.get(idx) != pgs) {
|
if (progresses.get(idx) != pgs) {
|
||||||
SwingUtils.setValueAt(lstDownload, pgs + "%", idx, 1);
|
SwingUtils.setValueAt(lstDownload, pgs + "%", idx, 1);
|
||||||
progresses.set(idx, pgs);
|
progresses.set(idx, pgs);
|
||||||
}
|
}
|
||||||
if(task.isParallelExecuting()) return;
|
if (task.isParallelExecuting()) return;
|
||||||
pgsSingle.setMaximum(max);
|
pgsSingle.setMaximum(max);
|
||||||
pgsSingle.setValue(progress);
|
pgsSingle.setValue(progress);
|
||||||
});
|
});
|
||||||
@@ -266,6 +266,7 @@ public class TaskWindow extends javax.swing.JDialog
|
|||||||
pgsTotal.setMaximum(taskList.taskCount());
|
pgsTotal.setMaximum(taskList.taskCount());
|
||||||
pgsTotal.setValue(pgsTotal.getValue() + 1);
|
pgsTotal.setValue(pgsTotal.getValue() + 1);
|
||||||
int idx = tasks.indexOf(task);
|
int idx = tasks.indexOf(task);
|
||||||
|
if (idx == -1) return;
|
||||||
SwingUtils.setValueAt(lstDownload, task.getFailReason(), idx, 0);
|
SwingUtils.setValueAt(lstDownload, task.getFailReason(), idx, 0);
|
||||||
SwingUtils.setValueAt(lstDownload, "0%", idx, 1);
|
SwingUtils.setValueAt(lstDownload, "0%", idx, 1);
|
||||||
SwingUtils.moveEnd(srlDownload);
|
SwingUtils.moveEnd(srlDownload);
|
||||||
|
|||||||
@@ -105,7 +105,7 @@ public class FileDownloadTask extends Task implements PreviousResult<File>, Prev
|
|||||||
|
|
||||||
RandomAccessFile file = null;
|
RandomAccessFile file = null;
|
||||||
InputStream stream = null;
|
InputStream stream = null;
|
||||||
boolean shouldContinue = true, aborted = false;
|
boolean shouldContinue = true;
|
||||||
|
|
||||||
private void closeFiles() {
|
private void closeFiles() {
|
||||||
// Close file.
|
// Close file.
|
||||||
@@ -199,7 +199,10 @@ public class FileDownloadTask extends Task implements PreviousResult<File>, Prev
|
|||||||
ppl.setProgress(this, downloaded, size);
|
ppl.setProgress(this, downloaded, size);
|
||||||
}
|
}
|
||||||
closeFiles();
|
closeFiles();
|
||||||
tempFile.renameTo(filePath);
|
if (aborted)
|
||||||
|
tempFile.delete();
|
||||||
|
else
|
||||||
|
tempFile.renameTo(filePath);
|
||||||
if (ppl != null)
|
if (ppl != null)
|
||||||
ppl.onProgressProviderDone(this);
|
ppl.onProgressProviderDone(this);
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -81,6 +81,7 @@ public class HTTPGetTask extends TaskInfo implements PreviousResult<String> {
|
|||||||
@Override
|
@Override
|
||||||
public boolean abort() {
|
public boolean abort() {
|
||||||
shouldContinue = false;
|
shouldContinue = false;
|
||||||
|
aborted = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -162,30 +162,20 @@ public final class JdkVersion {
|
|||||||
JavaProcess jp = new JavaProcess(str, pb.start(), null);
|
JavaProcess jp = new JavaProcess(str, pb.start(), null);
|
||||||
InputStream is = jp.getRawProcess().getErrorStream();
|
InputStream is = jp.getRawProcess().getErrorStream();
|
||||||
BufferedReader br = null;
|
BufferedReader br = null;
|
||||||
int lineNumber = 0;
|
|
||||||
String ver = null;
|
String ver = null;
|
||||||
Platform platform = Platform.UNKNOWN;
|
Platform platform = Platform.BIT_32;
|
||||||
try {
|
try {
|
||||||
br = new BufferedReader(new InputStreamReader(is));
|
br = new BufferedReader(new InputStreamReader(is));
|
||||||
String line;
|
String line;
|
||||||
jp.getRawProcess().waitFor();
|
jp.getRawProcess().waitFor();
|
||||||
while ((line = br.readLine()) != null) {
|
while ((line = br.readLine()) != null) {
|
||||||
lineNumber++;
|
Matcher m = p.matcher(line);
|
||||||
switch (lineNumber) {
|
if (m.find()) {
|
||||||
case 1:
|
ver = m.group();
|
||||||
Matcher m = p.matcher(line);
|
ver = ver.substring("java version \"".length(), ver.length() - 1);
|
||||||
if (m.find()) {
|
|
||||||
ver = m.group();
|
|
||||||
ver = ver.substring("java version \"".length(), ver.length() - 1);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
if (line.contains("64-Bit"))
|
|
||||||
platform = Platform.BIT_64;
|
|
||||||
else
|
|
||||||
platform = Platform.BIT_32;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
if (line.contains("64-Bit"))
|
||||||
|
platform = Platform.BIT_64;
|
||||||
}
|
}
|
||||||
} catch (InterruptedException | IOException e) {
|
} catch (InterruptedException | IOException e) {
|
||||||
HMCLog.warn("Failed to get java version", e);
|
HMCLog.warn("Failed to get java version", e);
|
||||||
|
|||||||
Reference in New Issue
Block a user