mirror of
https://github.com/tonikelope/megabasterd.git
synced 2025-05-06 09:34:35 +02:00
7.9
- Trying to fix already connected error - Improving pause all button
This commit is contained in:
parent
a06f4eb3cd
commit
98f6f82b0d
2
pom.xml
2
pom.xml
@ -3,7 +3,7 @@
|
|||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>com.tonikelope</groupId>
|
<groupId>com.tonikelope</groupId>
|
||||||
<artifactId>MegaBasterd</artifactId>
|
<artifactId>MegaBasterd</artifactId>
|
||||||
<version>7.8</version>
|
<version>7.9</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -24,7 +24,6 @@ public class ChunkDownloader implements Runnable, SecureSingleThreadNotifiable {
|
|||||||
|
|
||||||
public static final double SLOW_PROXY_PERC = 0.5;
|
public static final double SLOW_PROXY_PERC = 0.5;
|
||||||
private static final Logger LOG = Logger.getLogger(ChunkDownloader.class.getName());
|
private static final Logger LOG = Logger.getLogger(ChunkDownloader.class.getName());
|
||||||
private final boolean FORCE_SMART_PROXY = false; //True for debugging SmartProxy
|
|
||||||
private final int _id;
|
private final int _id;
|
||||||
private final Download _download;
|
private final Download _download;
|
||||||
private volatile boolean _exit;
|
private volatile boolean _exit;
|
||||||
@ -130,7 +129,7 @@ public class ChunkDownloader implements Runnable, SecureSingleThreadNotifiable {
|
|||||||
|
|
||||||
SmartMegaProxyManager proxy_manager = MainPanel.getProxy_manager();
|
SmartMegaProxyManager proxy_manager = MainPanel.getProxy_manager();
|
||||||
|
|
||||||
if (FORCE_SMART_PROXY) {
|
if (MainPanel.FORCE_SMART_PROXY) {
|
||||||
|
|
||||||
_current_smart_proxy = proxy_manager.getProxy(_excluded_proxy_list);
|
_current_smart_proxy = proxy_manager.getProxy(_excluded_proxy_list);
|
||||||
|
|
||||||
@ -141,12 +140,16 @@ public class ChunkDownloader implements Runnable, SecureSingleThreadNotifiable {
|
|||||||
|
|
||||||
while (!_download.getMain_panel().isExit() && !_exit && !_download.isStopped()) {
|
while (!_download.getMain_panel().isExit() && !_exit && !_download.isStopped()) {
|
||||||
|
|
||||||
if (_download.isPaused() && !_download.isStopped()) {
|
if (_download.isPaused() && !_download.isStopped() && !_download.getChunkmanager().isExit()) {
|
||||||
|
|
||||||
_download.pause_worker();
|
_download.pause_worker();
|
||||||
|
|
||||||
|
pause_init_time = System.currentTimeMillis();
|
||||||
|
|
||||||
secureWait();
|
secureWait();
|
||||||
|
|
||||||
|
paused += System.currentTimeMillis() - pause_init_time;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (worker_url == null || http_error == 403) {
|
if (worker_url == null || http_error == 403) {
|
||||||
@ -362,17 +365,13 @@ public class ChunkDownloader implements Runnable, SecureSingleThreadNotifiable {
|
|||||||
|
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
if (!FORCE_SMART_PROXY) {
|
|
||||||
_current_smart_proxy = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
_excluded_proxy_list.clear();
|
_excluded_proxy_list.clear();
|
||||||
|
|
||||||
_download.getChunkmanager().secureNotify();
|
_download.getChunkmanager().secureNotify();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (IOException ex) {
|
} catch (IOException | IllegalStateException ex) {
|
||||||
|
|
||||||
if (ex instanceof SocketTimeoutException) {
|
if (ex instanceof SocketTimeoutException) {
|
||||||
timeout = true;
|
timeout = true;
|
||||||
@ -417,6 +416,9 @@ public class ChunkDownloader implements Runnable, SecureSingleThreadNotifiable {
|
|||||||
} else if (http_error == 503 && _current_smart_proxy == null && !_download.isTurbo()) {
|
} else if (http_error == 503 && _current_smart_proxy == null && !_download.isTurbo()) {
|
||||||
setExit(true);
|
setExit(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} else if (!FORCE_SMART_PROXY) {
|
||||||
|
_current_smart_proxy = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
con.disconnect();
|
con.disconnect();
|
||||||
|
@ -412,7 +412,6 @@ public class Download implements Transference, Runnable, SecureSingleThreadNotif
|
|||||||
public void stop() {
|
public void stop() {
|
||||||
|
|
||||||
if (!isExit()) {
|
if (!isExit()) {
|
||||||
getMain_panel().getDownload_manager().setPaused_all(false);
|
|
||||||
_canceled = true;
|
_canceled = true;
|
||||||
stopDownloader();
|
stopDownloader();
|
||||||
}
|
}
|
||||||
@ -425,8 +424,6 @@ public class Download implements Transference, Runnable, SecureSingleThreadNotif
|
|||||||
|
|
||||||
setPause(false);
|
setPause(false);
|
||||||
|
|
||||||
getMain_panel().getDownload_manager().setPaused_all(false);
|
|
||||||
|
|
||||||
setPaused_workers(0);
|
setPaused_workers(0);
|
||||||
|
|
||||||
synchronized (_workers_lock) {
|
synchronized (_workers_lock) {
|
||||||
@ -438,6 +435,8 @@ public class Download implements Transference, Runnable, SecureSingleThreadNotif
|
|||||||
|
|
||||||
getView().resume();
|
getView().resume();
|
||||||
|
|
||||||
|
_main_panel.getDownload_manager().setPaused_all(false);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
setPause(true);
|
setPause(true);
|
||||||
@ -1119,7 +1118,7 @@ public class Download implements Transference, Runnable, SecureSingleThreadNotif
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDownloadUrlForWorker() throws IOException {
|
public String getDownloadUrlForWorker() {
|
||||||
|
|
||||||
synchronized (_dl_url_lock) {
|
synchronized (_dl_url_lock) {
|
||||||
|
|
||||||
@ -1156,7 +1155,7 @@ public class Download implements Transference, Runnable, SecureSingleThreadNotif
|
|||||||
error = true;
|
error = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (APIException ex) {
|
} catch (Exception ex) {
|
||||||
|
|
||||||
error = true;
|
error = true;
|
||||||
|
|
||||||
@ -1449,10 +1448,10 @@ public class Download implements Transference, Runnable, SecureSingleThreadNotif
|
|||||||
|
|
||||||
if (Arrays.asList(FATAL_API_ERROR_CODES).contains(error_code)) {
|
if (Arrays.asList(FATAL_API_ERROR_CODES).contains(error_code)) {
|
||||||
|
|
||||||
stopDownloader(ex.getMessage() + " " + truncateText(link, 80));
|
|
||||||
|
|
||||||
_auto_retry_on_error = Arrays.asList(FATAL_API_ERROR_CODES_WITH_RETRY).contains(error_code);
|
_auto_retry_on_error = Arrays.asList(FATAL_API_ERROR_CODES_WITH_RETRY).contains(error_code);
|
||||||
|
|
||||||
|
stopDownloader(ex.getMessage() + " " + truncateText(link, 80));
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
if (!retry_request) {
|
if (!retry_request) {
|
||||||
@ -1535,10 +1534,10 @@ public class Download implements Transference, Runnable, SecureSingleThreadNotif
|
|||||||
|
|
||||||
if (Arrays.asList(FATAL_API_ERROR_CODES).contains(error_code)) {
|
if (Arrays.asList(FATAL_API_ERROR_CODES).contains(error_code)) {
|
||||||
|
|
||||||
stopDownloader(ex.getMessage() + " " + truncateText(link, 80));
|
|
||||||
|
|
||||||
_auto_retry_on_error = Arrays.asList(FATAL_API_ERROR_CODES_WITH_RETRY).contains(error_code);
|
_auto_retry_on_error = Arrays.asList(FATAL_API_ERROR_CODES_WITH_RETRY).contains(error_code);
|
||||||
|
|
||||||
|
stopDownloader(ex.getMessage() + " " + truncateText(link, 80));
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
_retrying_request = true;
|
_retrying_request = true;
|
||||||
@ -1711,4 +1710,14 @@ public class Download implements Transference, Runnable, SecureSingleThreadNotif
|
|||||||
return _closed;
|
return _closed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getPausedWorkers() {
|
||||||
|
return _paused_workers;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getTotWorkers() {
|
||||||
|
return getChunkworkers().size();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -55,7 +55,8 @@ import javax.swing.UIManager;
|
|||||||
*/
|
*/
|
||||||
public final class MainPanel {
|
public final class MainPanel {
|
||||||
|
|
||||||
public static final String VERSION = "7.8";
|
public static final String VERSION = "7.9";
|
||||||
|
public static final boolean FORCE_SMART_PROXY = false; //TRUE FOR DEBUGING SMART PROXY
|
||||||
public static final int THROTTLE_SLICE_SIZE = 16 * 1024;
|
public static final int THROTTLE_SLICE_SIZE = 16 * 1024;
|
||||||
public static final int DEFAULT_BYTE_BUFFER_SIZE = 16 * 1024;
|
public static final int DEFAULT_BYTE_BUFFER_SIZE = 16 * 1024;
|
||||||
public static final int STREAMER_PORT = 1337;
|
public static final int STREAMER_PORT = 1337;
|
||||||
|
@ -1266,7 +1266,17 @@ public final class MainPanelView extends javax.swing.JFrame {
|
|||||||
|
|
||||||
private void pause_all_down_buttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pause_all_down_buttonActionPerformed
|
private void pause_all_down_buttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pause_all_down_buttonActionPerformed
|
||||||
|
|
||||||
|
pause_all_down_button.setEnabled(false);
|
||||||
|
|
||||||
|
if (!_main_panel.getDownload_manager().isPaused_all()) {
|
||||||
|
|
||||||
_main_panel.getDownload_manager().pauseAll();
|
_main_panel.getDownload_manager().pauseAll();
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
_main_panel.getDownload_manager().resumeAll();
|
||||||
|
}
|
||||||
|
|
||||||
}//GEN-LAST:event_pause_all_down_buttonActionPerformed
|
}//GEN-LAST:event_pause_all_down_buttonActionPerformed
|
||||||
|
|
||||||
private void new_stream_menuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_new_stream_menuActionPerformed
|
private void new_stream_menuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_new_stream_menuActionPerformed
|
||||||
|
@ -364,13 +364,19 @@ public class MegaAPI implements Serializable {
|
|||||||
|
|
||||||
SmartMegaProxyManager proxy_manager = MainPanel.getProxy_manager();
|
SmartMegaProxyManager proxy_manager = MainPanel.getProxy_manager();
|
||||||
|
|
||||||
|
if (MainPanel.FORCE_SMART_PROXY) {
|
||||||
|
|
||||||
|
current_smart_proxy = proxy_manager.getProxy(excluded_proxy_list);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
do {
|
do {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
if ((current_smart_proxy != null || http_error == 509) && MainPanel.isUse_smart_proxy() && !MainPanel.isUse_proxy()) {
|
if ((current_smart_proxy != null || http_error == 509) && MainPanel.isUse_smart_proxy() && !MainPanel.isUse_proxy()) {
|
||||||
|
|
||||||
if (current_smart_proxy != null && (http_error != 0 || mega_error != 0)) {
|
if (current_smart_proxy != null && (http_error != 0 || empty_response)) {
|
||||||
|
|
||||||
if (http_error == 509) {
|
if (http_error == 509) {
|
||||||
proxy_manager.blockProxy(current_smart_proxy);
|
proxy_manager.blockProxy(current_smart_proxy);
|
||||||
@ -419,20 +425,20 @@ public class MegaAPI implements Serializable {
|
|||||||
|
|
||||||
mega_error = 0;
|
mega_error = 0;
|
||||||
|
|
||||||
empty_response = true;
|
empty_response = false;
|
||||||
|
|
||||||
con.setRequestMethod("POST");
|
|
||||||
|
|
||||||
con.setRequestProperty("Content-type", "text/plain;charset=UTF-8");
|
con.setRequestProperty("Content-type", "text/plain;charset=UTF-8");
|
||||||
|
|
||||||
con.setRequestProperty("User-Agent", MainPanel.DEFAULT_USER_AGENT);
|
con.setRequestProperty("User-Agent", MainPanel.DEFAULT_USER_AGENT);
|
||||||
|
|
||||||
|
con.setUseCaches(false);
|
||||||
|
|
||||||
|
con.setRequestMethod("POST");
|
||||||
|
|
||||||
con.setDoOutput(true);
|
con.setDoOutput(true);
|
||||||
|
|
||||||
con.getOutputStream().write(request.getBytes("UTF-8"));
|
con.getOutputStream().write(request.getBytes("UTF-8"));
|
||||||
|
|
||||||
con.getOutputStream().flush();
|
|
||||||
|
|
||||||
con.getOutputStream().close();
|
con.getOutputStream().close();
|
||||||
|
|
||||||
http_status = con.getResponseCode();
|
http_status = con.getResponseCode();
|
||||||
@ -462,10 +468,17 @@ public class MegaAPI implements Serializable {
|
|||||||
|
|
||||||
if (response.length() > 0) {
|
if (response.length() > 0) {
|
||||||
|
|
||||||
empty_response = false;
|
|
||||||
|
|
||||||
mega_error = checkMEGAError(response);
|
mega_error = checkMEGAError(response);
|
||||||
|
|
||||||
|
if (mega_error != 0 && !Arrays.asList(MEGA_ERROR_NO_EXCEPTION_CODES).contains(mega_error)) {
|
||||||
|
|
||||||
|
throw new MegaAPIException(mega_error);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
empty_response = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -483,12 +496,7 @@ public class MegaAPI implements Serializable {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty_response && mega_error != 0 && http_error != 509) {
|
if ((empty_response || mega_error != 0 || http_error != 0) && http_error != 509) {
|
||||||
|
|
||||||
if (!Arrays.asList(MEGA_ERROR_NO_EXCEPTION_CODES).contains(mega_error)) {
|
|
||||||
|
|
||||||
throw new MegaAPIException(mega_error);
|
|
||||||
}
|
|
||||||
|
|
||||||
LOG.log(Level.WARNING, "{0} MegaAPI ERROR {1} Waiting for retry...", new Object[]{Thread.currentThread().getName(), String.valueOf(mega_error)});
|
LOG.log(Level.WARNING, "{0} MegaAPI ERROR {1} Waiting for retry...", new Object[]{Thread.currentThread().getName(), String.valueOf(mega_error)});
|
||||||
|
|
||||||
@ -498,12 +506,9 @@ public class MegaAPI implements Serializable {
|
|||||||
LOG.log(Level.SEVERE, ex.getMessage());
|
LOG.log(Level.SEVERE, ex.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (!empty_response && mega_error == 0 && http_error == 0) {
|
|
||||||
|
|
||||||
conta_error = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} while (empty_response || mega_error != 0 || (http_error == 509 && MainPanel.isUse_smart_proxy()));
|
} while (empty_response || mega_error != 0 || (http_error == 509 && MainPanel.isUse_smart_proxy() && !MainPanel.isUse_proxy()));
|
||||||
|
|
||||||
_seqno++;
|
_seqno++;
|
||||||
|
|
||||||
@ -511,7 +516,7 @@ public class MegaAPI implements Serializable {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getMegaFileDownloadUrl(String link) throws IOException, MegaAPIException {
|
public String getMegaFileDownloadUrl(String link) throws MegaAPIException, MalformedURLException, IOException {
|
||||||
|
|
||||||
String file_id = findFirstRegex("#.*?!([^!]+)", link, 1);
|
String file_id = findFirstRegex("#.*?!([^!]+)", link, 1);
|
||||||
|
|
||||||
|
@ -851,8 +851,6 @@ public class MiscTools {
|
|||||||
|
|
||||||
HttpURLConnection con = null;
|
HttpURLConnection con = null;
|
||||||
|
|
||||||
boolean error = false;
|
|
||||||
|
|
||||||
int http_status = 0, http_error = 0;
|
int http_status = 0, http_error = 0;
|
||||||
|
|
||||||
SmartMegaProxyManager proxy_manager = MainPanel.getProxy_manager();
|
SmartMegaProxyManager proxy_manager = MainPanel.getProxy_manager();
|
||||||
@ -861,17 +859,21 @@ public class MiscTools {
|
|||||||
|
|
||||||
ArrayList<String> excluded_proxy_list = new ArrayList<>();
|
ArrayList<String> excluded_proxy_list = new ArrayList<>();
|
||||||
|
|
||||||
|
if (MainPanel.FORCE_SMART_PROXY) {
|
||||||
|
|
||||||
|
current_smart_proxy = proxy_manager.getProxy(excluded_proxy_list);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
do {
|
do {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
URL url = new URL(string_url + "/0-0");
|
URL url = new URL(string_url + "/0-0");
|
||||||
|
|
||||||
if (con == null || error) {
|
|
||||||
|
|
||||||
if ((current_smart_proxy != null || http_error == 509) && MainPanel.isUse_smart_proxy() && !MainPanel.isUse_proxy()) {
|
if ((current_smart_proxy != null || http_error == 509) && MainPanel.isUse_smart_proxy() && !MainPanel.isUse_proxy()) {
|
||||||
|
|
||||||
if (current_smart_proxy != null && error) {
|
if (current_smart_proxy != null && http_error != 0) {
|
||||||
|
|
||||||
if (http_error == 509) {
|
if (http_error == 509) {
|
||||||
proxy_manager.blockProxy(current_smart_proxy);
|
proxy_manager.blockProxy(current_smart_proxy);
|
||||||
@ -926,8 +928,6 @@ public class MiscTools {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if (current_smart_proxy != null) {
|
if (current_smart_proxy != null) {
|
||||||
con.setConnectTimeout(Transference.HTTP_PROXY_CONNECT_TIMEOUT);
|
con.setConnectTimeout(Transference.HTTP_PROXY_CONNECT_TIMEOUT);
|
||||||
con.setReadTimeout(Transference.HTTP_PROXY_READ_TIMEOUT);
|
con.setReadTimeout(Transference.HTTP_PROXY_READ_TIMEOUT);
|
||||||
@ -941,15 +941,18 @@ public class MiscTools {
|
|||||||
|
|
||||||
if (http_status != 200) {
|
if (http_status != 200) {
|
||||||
http_error = http_status;
|
http_error = http_status;
|
||||||
|
} else {
|
||||||
|
http_error = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (IOException ex) {
|
} catch (Exception ex) {
|
||||||
Logger.getLogger(MiscTools.class.getName()).log(Level.SEVERE, ex.getMessage());
|
Logger.getLogger(MiscTools.class.getName()).log(Level.SEVERE, ex.getMessage());
|
||||||
} finally {
|
} finally {
|
||||||
|
|
||||||
if (con != null) {
|
if (con != null) {
|
||||||
con.disconnect();
|
con.disconnect();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} while (http_error == 509);
|
} while (http_error == 509);
|
||||||
|
@ -55,6 +55,12 @@ public class StreamChunkDownloader implements Runnable {
|
|||||||
|
|
||||||
ArrayList<String> excluded_proxy_list = new ArrayList<>();
|
ArrayList<String> excluded_proxy_list = new ArrayList<>();
|
||||||
|
|
||||||
|
if (MainPanel.FORCE_SMART_PROXY) {
|
||||||
|
|
||||||
|
current_smart_proxy = proxy_manager.getProxy(excluded_proxy_list);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
while (!_exit && !_chunkmanager.isExit()) {
|
while (!_exit && !_chunkmanager.isExit()) {
|
||||||
|
|
||||||
while (!_exit && !_chunkmanager.isExit() && _chunkmanager.getChunk_queue().size() >= StreamChunkManager.BUFFER_CHUNKS_SIZE) {
|
while (!_exit && !_chunkmanager.isExit() && _chunkmanager.getChunk_queue().size() >= StreamChunkManager.BUFFER_CHUNKS_SIZE) {
|
||||||
|
@ -10,8 +10,8 @@ public interface Transference {
|
|||||||
|
|
||||||
int MIN_WORKERS = 1;
|
int MIN_WORKERS = 1;
|
||||||
int MAX_WORKERS = 20;
|
int MAX_WORKERS = 20;
|
||||||
int HTTP_PROXY_CONNECT_TIMEOUT = 15000;
|
int HTTP_PROXY_CONNECT_TIMEOUT = 20000;
|
||||||
int HTTP_PROXY_READ_TIMEOUT = 15000;
|
int HTTP_PROXY_READ_TIMEOUT = 20000;
|
||||||
int HTTP_CONNECT_TIMEOUT = 60000;
|
int HTTP_CONNECT_TIMEOUT = 60000;
|
||||||
int HTTP_READ_TIMEOUT = 60000;
|
int HTTP_READ_TIMEOUT = 60000;
|
||||||
int MAX_SIM_TRANSFERENCES = 20;
|
int MAX_SIM_TRANSFERENCES = 20;
|
||||||
@ -79,4 +79,8 @@ public interface Transference {
|
|||||||
|
|
||||||
int getSlotsCount();
|
int getSlotsCount();
|
||||||
|
|
||||||
|
int getPausedWorkers();
|
||||||
|
|
||||||
|
int getTotWorkers();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -39,6 +39,7 @@ abstract public class TransferenceManager implements Runnable, SecureSingleThrea
|
|||||||
private final MainPanel _main_panel;
|
private final MainPanel _main_panel;
|
||||||
private final Object _secure_notify_lock;
|
private final Object _secure_notify_lock;
|
||||||
private final Object _wait_queue_lock;
|
private final Object _wait_queue_lock;
|
||||||
|
private final Object _pause_all_lock;
|
||||||
private boolean _notified;
|
private boolean _notified;
|
||||||
private volatile boolean _removing_transferences;
|
private volatile boolean _removing_transferences;
|
||||||
private volatile boolean _provisioning_transferences;
|
private volatile boolean _provisioning_transferences;
|
||||||
@ -67,6 +68,7 @@ abstract public class TransferenceManager implements Runnable, SecureSingleThrea
|
|||||||
_max_running_trans = max_running_trans;
|
_max_running_trans = max_running_trans;
|
||||||
_scroll_panel = scroll_panel;
|
_scroll_panel = scroll_panel;
|
||||||
_status = status;
|
_status = status;
|
||||||
|
_pause_all_lock = new Object();
|
||||||
_close_all_button = close_all_button;
|
_close_all_button = close_all_button;
|
||||||
_pause_all_button = pause_all_button;
|
_pause_all_button = pause_all_button;
|
||||||
_clean_all_menu = clean_all_menu;
|
_clean_all_menu = clean_all_menu;
|
||||||
@ -96,6 +98,10 @@ abstract public class TransferenceManager implements Runnable, SecureSingleThrea
|
|||||||
this._sort_wait_start_queue = sort_wait_start_queue;
|
this._sort_wait_start_queue = sort_wait_start_queue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setPaused_all(boolean _paused_all) {
|
||||||
|
this._paused_all = _paused_all;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isFrozen() {
|
public boolean isFrozen() {
|
||||||
return _frozen;
|
return _frozen;
|
||||||
}
|
}
|
||||||
@ -112,10 +118,6 @@ abstract public class TransferenceManager implements Runnable, SecureSingleThrea
|
|||||||
return _wait_queue_lock;
|
return _wait_queue_lock;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPaused_all(boolean paused_all) {
|
|
||||||
_paused_all = paused_all;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ConcurrentLinkedQueue<Object> getTransference_preprocess_global_queue() {
|
public ConcurrentLinkedQueue<Object> getTransference_preprocess_global_queue() {
|
||||||
return _transference_preprocess_global_queue;
|
return _transference_preprocess_global_queue;
|
||||||
}
|
}
|
||||||
@ -481,10 +483,78 @@ abstract public class TransferenceManager implements Runnable, SecureSingleThrea
|
|||||||
|
|
||||||
public void pauseAll() {
|
public void pauseAll() {
|
||||||
|
|
||||||
_paused_all = !_paused_all;
|
_transference_running_list.forEach((transference) -> {
|
||||||
|
|
||||||
|
if (!transference.isPaused()) {
|
||||||
|
transference.pause();
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
secureNotify();
|
||||||
|
|
||||||
|
THREAD_POOL.execute(() -> {
|
||||||
|
|
||||||
|
boolean running;
|
||||||
|
|
||||||
|
do {
|
||||||
|
|
||||||
|
running = false;
|
||||||
|
|
||||||
|
for (Transference t : _transference_running_list) {
|
||||||
|
if (t.getPausedWorkers() != t.getTotWorkers()) {
|
||||||
|
running = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (running) {
|
||||||
|
synchronized (_pause_all_lock) {
|
||||||
|
|
||||||
|
try {
|
||||||
|
_pause_all_lock.wait(1000);
|
||||||
|
} catch (InterruptedException ex) {
|
||||||
|
Logger.getLogger(TransferenceManager.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} while (running);
|
||||||
|
|
||||||
|
_paused_all = true;
|
||||||
|
|
||||||
|
swingInvoke(() -> {
|
||||||
|
|
||||||
|
_pause_all_button.setText("RESUME ALL");
|
||||||
|
_pause_all_button.setEnabled(true);
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
secureNotify();
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void resumeAll() {
|
||||||
|
|
||||||
_transference_running_list.forEach((transference) -> {
|
_transference_running_list.forEach((transference) -> {
|
||||||
|
|
||||||
|
if (transference.isPaused()) {
|
||||||
transference.pause();
|
transference.pause();
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
_paused_all = false;
|
||||||
|
|
||||||
|
swingInvoke(() -> {
|
||||||
|
|
||||||
|
_pause_all_button.setText("PAUSE ALL");
|
||||||
|
|
||||||
|
_pause_all_button.setEnabled(true);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
secureNotify();
|
secureNotify();
|
||||||
|
@ -488,7 +488,6 @@ public class Upload implements Transference, Runnable, SecureSingleThreadNotifia
|
|||||||
@Override
|
@Override
|
||||||
public void stop() {
|
public void stop() {
|
||||||
if (!isExit()) {
|
if (!isExit()) {
|
||||||
getMain_panel().getUpload_manager().setPaused_all(false);
|
|
||||||
_canceled = true;
|
_canceled = true;
|
||||||
stopUploader();
|
stopUploader();
|
||||||
}
|
}
|
||||||
@ -501,8 +500,6 @@ public class Upload implements Transference, Runnable, SecureSingleThreadNotifia
|
|||||||
|
|
||||||
setPause(false);
|
setPause(false);
|
||||||
|
|
||||||
getMain_panel().getUpload_manager().setPaused_all(false);
|
|
||||||
|
|
||||||
setPaused_workers(0);
|
setPaused_workers(0);
|
||||||
|
|
||||||
synchronized (_workers_lock) {
|
synchronized (_workers_lock) {
|
||||||
@ -514,6 +511,8 @@ public class Upload implements Transference, Runnable, SecureSingleThreadNotifia
|
|||||||
|
|
||||||
getView().resume();
|
getView().resume();
|
||||||
|
|
||||||
|
_main_panel.getUpload_manager().setPaused_all(false);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
setPause(true);
|
setPause(true);
|
||||||
@ -1311,4 +1310,13 @@ public class Upload implements Transference, Runnable, SecureSingleThreadNotifia
|
|||||||
return _closed;
|
return _closed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getPausedWorkers() {
|
||||||
|
return _paused_workers;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getTotWorkers() {
|
||||||
|
return getChunkworkers().size();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 192 KiB After Width: | Height: | Size: 189 KiB |
Loading…
x
Reference in New Issue
Block a user