Skip to content

Commit 07d8ed7

Browse files
author
tonikelope
committed
7.50
Trying to MITIGATE: #394 #391 (NEW CANCEL ALL DOWNLOADS MENU ITEM)
1 parent e35f87f commit 07d8ed7

File tree

9 files changed

+436
-391
lines changed

9 files changed

+436
-391
lines changed

pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<modelVersion>4.0.0</modelVersion>
44
<groupId>com.tonikelope</groupId>
55
<artifactId>MegaBasterd</artifactId>
6-
<version>7.49</version>
6+
<version>7.50</version>
77
<packaging>jar</packaging>
88
<dependencies>
99
<dependency>

src/main/java/com/tonikelope/megabasterd/Download.java

+13-4
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,11 @@ public class Download implements Transference, Runnable, SecureSingleThreadNotif
100100
private volatile boolean _finalizing;
101101
private final Object _progress_watchdog_lock;
102102
private final boolean _priority;
103+
private volatile boolean global_cancel = false;
104+
105+
public void setGlobal_cancel(boolean global_cancel) {
106+
this.global_cancel = global_cancel;
107+
}
103108

104109
public String getStatus_error() {
105110
return _status_error;
@@ -204,7 +209,7 @@ public boolean isPriority() {
204209
}
205210

206211
public boolean isCanceled() {
207-
return _canceled;
212+
return (_canceled && !global_cancel);
208213
}
209214

210215
public boolean isTurbo() {
@@ -911,7 +916,7 @@ public void run() {
911916
}
912917
}
913918

914-
if (_status_error == null && !_canceled) {
919+
if ((_status_error == null && !_canceled) || global_cancel || !_auto_retry_on_error) {
915920

916921
try {
917922
deleteDownload(_url);
@@ -936,11 +941,11 @@ public void run() {
936941
MiscTools.GUIRun(() -> {
937942
getView().getClose_button().setVisible(true);
938943

939-
if ((_status_error != null || _canceled) && isProvision_ok()) {
944+
if ((_status_error != null || _canceled) && isProvision_ok() && !global_cancel) {
940945

941946
getView().getRestart_button().setVisible(true);
942947

943-
} else {
948+
} else if (!global_cancel) {
944949

945950
getView().getClose_button().setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/icons8-ok-30.png")));
946951
}
@@ -968,6 +973,10 @@ public void run() {
968973

969974
_exit = true;
970975

976+
if (_status_error != null && !_canceled && getMain_panel().getDownload_manager().no_transferences() && getMain_panel().getUpload_manager().no_transferences() && (!getMain_panel().getDownload_manager().getTransference_finished_queue().isEmpty() || !getMain_panel().getUpload_manager().getTransference_finished_queue().isEmpty()) && getMain_panel().getView().getAuto_close_menu().isSelected()) {
977+
System.exit(0);
978+
}
979+
971980
synchronized (_progress_watchdog_lock) {
972981
_progress_watchdog_lock.notifyAll();
973982
}

src/main/java/com/tonikelope/megabasterd/DownloadManager.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public DownloadManager(MainPanel main_panel) {
2424
@Override
2525
public void closeAllFinished() {
2626

27-
_transference_finished_queue.stream().filter((t) -> ((!t.isStatusError() || ((Download) t).getStatus_error().equals("FILE WITH SAME NAME AND SIZE ALREADY EXISTS")) && !t.isCanceled())).map((t) -> {
27+
_transference_finished_queue.stream().filter((t) -> (!t.isCanceled())).map((t) -> {
2828
_transference_finished_queue.remove(t);
2929
return t;
3030
}).forEachOrdered((t) -> {

src/main/java/com/tonikelope/megabasterd/MainPanel.java

+1-40
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@
3838
import java.util.HashMap;
3939
import java.util.Iterator;
4040
import java.util.Map;
41-
import java.util.Timer;
42-
import java.util.TimerTask;
4341
import java.util.UUID;
4442
import java.util.concurrent.ExecutorService;
4543
import static java.util.concurrent.Executors.newCachedThreadPool;
@@ -60,7 +58,7 @@
6058
*/
6159
public final class MainPanel {
6260

63-
public static final String VERSION = "7.49";
61+
public static final String VERSION = "7.50";
6462
public static final boolean FORCE_SMART_PROXY = false; //TRUE FOR DEBUGING SMART PROXY
6563
public static final int THROTTLE_SLICE_SIZE = 16 * 1024;
6664
public static final int DEFAULT_BYTE_BUFFER_SIZE = 16 * 1024;
@@ -302,43 +300,6 @@ public MainPanel() {
302300

303301
THREAD_POOL.execute((_clipboardspy = new ClipboardSpy()));
304302

305-
THREAD_POOL.execute(() -> {
306-
Object timer_lock = new Object();
307-
308-
Timer timer = new Timer();
309-
310-
TimerTask task = new TimerTask() {
311-
312-
@Override
313-
public void run() {
314-
synchronized (timer_lock) {
315-
316-
timer_lock.notify();
317-
}
318-
}
319-
};
320-
321-
timer.schedule(task, 0, 5000);
322-
323-
while (true) {
324-
325-
synchronized (timer_lock) {
326-
327-
try {
328-
329-
if (_download_manager.no_transferences() && _upload_manager.no_transferences() && (!_download_manager.getTransference_finished_queue().isEmpty() || !_upload_manager.getTransference_finished_queue().isEmpty()) && getView().getAuto_close_menu().isSelected()) {
330-
System.exit(0);
331-
}
332-
333-
timer_lock.wait();
334-
} catch (InterruptedException ex) {
335-
LOG.log(Level.SEVERE, ex.getMessage());
336-
}
337-
}
338-
339-
}
340-
});
341-
342303
try {
343304
_streamserver = new KissVideoStreamServer(this);
344305
_streamserver.start(STREAMER_PORT, "/video");

src/main/java/com/tonikelope/megabasterd/MainPanelView.form

+14
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,20 @@
115115
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="clean_all_up_menuActionPerformed"/>
116116
</Events>
117117
</MenuItem>
118+
<MenuItem class="javax.swing.JMenuItem" name="jMenuItem1">
119+
<Properties>
120+
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
121+
<Font name="Dialog" size="18" style="0"/>
122+
</Property>
123+
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
124+
<Image iconType="3" name="/images/icons8-minus-30.png"/>
125+
</Property>
126+
<Property name="text" type="java.lang.String" value="CANCEL ALL DOWNLOADS"/>
127+
</Properties>
128+
<Events>
129+
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jMenuItem1ActionPerformed"/>
130+
</Events>
131+
</MenuItem>
118132
<MenuItem class="javax.swing.JPopupMenu$Separator" name="jSeparator2">
119133
</MenuItem>
120134
<MenuItem class="javax.swing.JMenuItem" name="hide_tray_menu">

0 commit comments

Comments
 (0)