diff --git a/pom.xml b/pom.xml index 401678ee2..2e8ba07cf 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 com.tonikelope MegaBasterd - 6.77 + 6.78 jar diff --git a/src/main/java/com/tonikelope/megabasterd/ChunkDownloader.java b/src/main/java/com/tonikelope/megabasterd/ChunkDownloader.java index e3e29a7fa..b89dad748 100644 --- a/src/main/java/com/tonikelope/megabasterd/ChunkDownloader.java +++ b/src/main/java/com/tonikelope/megabasterd/ChunkDownloader.java @@ -1,6 +1,7 @@ package com.tonikelope.megabasterd; import static com.tonikelope.megabasterd.MainPanel.*; +import static com.tonikelope.megabasterd.MiscTools.formatBytes; import java.io.BufferedOutputStream; import java.io.File; import java.io.FileOutputStream; @@ -22,7 +23,6 @@ import java.util.logging.Logger; public class ChunkDownloader implements Runnable, SecureSingleThreadNotifiable { public static final double SLOW_PROXY_PERC = 0.3; - public static final int READ_TIMEOUT_RETRY = 3; 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; @@ -276,7 +276,7 @@ public class ChunkDownloader implements Runnable, SecureSingleThreadNotifiable { _download.getProgress_meter().secureNotify(); - if (_download.isPaused() && !_download.isStopped()) { + if (_download.isPaused() && !_exit && !_download.isStopped() && !_download.getChunkmanager().isExit() && chunk_reads < chunk_size) { _download.pause_worker(); @@ -328,9 +328,7 @@ public class ChunkDownloader implements Runnable, SecureSingleThreadNotifiable { http_error = 0; - /* - //Proxy speed benchmark - + //Proxy speed benchmark if (_current_smart_proxy != null && finish_chunk_time != -1) { //Update average chunk download speed using SmartProxy @@ -341,7 +339,7 @@ public class ChunkDownloader implements Runnable, SecureSingleThreadNotifiable { long avg_chunk_speed = _download.getMain_panel().getGlobal_dl_speed().getAvg_chunk_speed(); if (avg_chunk_speed != -1) { - + if (chunk_speed < Math.round(avg_chunk_speed * SLOW_PROXY_PERC)) { LOG.log(Level.INFO, "{0} Worker [{1}] WARNING -> PROXY {2} CHUNK DOWNLOAD SPEED: {3}/s SEEMS TO BE SLOW (average is {4}/s) {4}", new Object[]{Thread.currentThread().getName(), _id, _current_smart_proxy, formatBytes(chunk_speed), formatBytes(avg_chunk_speed), _download.getFile_name()}); @@ -349,8 +347,9 @@ public class ChunkDownloader implements Runnable, SecureSingleThreadNotifiable { slow_proxy = true; } } - - }*/ + + } + if (!FORCE_SMART_PROXY) { _current_smart_proxy = null; } diff --git a/src/main/java/com/tonikelope/megabasterd/ChunkDownloaderMono.java b/src/main/java/com/tonikelope/megabasterd/ChunkDownloaderMono.java index 95d0c9204..c00a6ca7d 100644 --- a/src/main/java/com/tonikelope/megabasterd/ChunkDownloaderMono.java +++ b/src/main/java/com/tonikelope/megabasterd/ChunkDownloaderMono.java @@ -136,7 +136,7 @@ public class ChunkDownloaderMono extends ChunkDownloader { getDownload().getProgress_meter().secureNotify(); - if (getDownload().isPaused() && !getDownload().isStopped()) { + if (getDownload().isPaused() && !getDownload().isStopped() && chunk_reads < chunk_size) { getDownload().pause_worker_mono(); diff --git a/src/main/java/com/tonikelope/megabasterd/ChunkUploader.java b/src/main/java/com/tonikelope/megabasterd/ChunkUploader.java index 570411608..7b2fbdfe8 100644 --- a/src/main/java/com/tonikelope/megabasterd/ChunkUploader.java +++ b/src/main/java/com/tonikelope/megabasterd/ChunkUploader.java @@ -188,7 +188,7 @@ public class ChunkUploader implements Runnable, SecureSingleThreadNotifiable { tot_bytes_up += reads; - if (_upload.isPaused() && !_upload.isStopped()) { + if (_upload.isPaused() && !_exit && !_upload.isStopped() && tot_bytes_up < chunk_size) { _upload.pause_worker(); diff --git a/src/main/java/com/tonikelope/megabasterd/Download.java b/src/main/java/com/tonikelope/megabasterd/Download.java index fdc8eecd1..170fc57d9 100644 --- a/src/main/java/com/tonikelope/megabasterd/Download.java +++ b/src/main/java/com/tonikelope/megabasterd/Download.java @@ -655,9 +655,9 @@ public class Download implements Transference, Runnable, SecureSingleThreadNotif } } - } while (!isExit() && (!isTurbo() || isPaused() || progress > last_progress)); + } while (!isExit() && progress < getFile_size() && (!isTurbo() || isPaused() || progress > last_progress)); - if (!isExit() && progress <= last_progress) { + if (!isExit() && progress < getFile_size() && progress <= last_progress) { stopDownloader("PROGRESS WATCHDOG TIMEOUT!"); MainPanel.getProxy_manager().refreshProxyList(); //Force SmartProxy proxy list refresh } diff --git a/src/main/java/com/tonikelope/megabasterd/MainPanel.java b/src/main/java/com/tonikelope/megabasterd/MainPanel.java index 917fd000e..6433234a9 100644 --- a/src/main/java/com/tonikelope/megabasterd/MainPanel.java +++ b/src/main/java/com/tonikelope/megabasterd/MainPanel.java @@ -53,7 +53,7 @@ import javax.swing.UIManager; */ public final class MainPanel { - public static final String VERSION = "6.77"; + public static final String VERSION = "6.78"; public static final int THROTTLE_SLICE_SIZE = 16 * 1024; public static final int DEFAULT_BYTE_BUFFER_SIZE = 16 * 1024; public static final int STREAMER_PORT = 1337; diff --git a/src/main/java/com/tonikelope/megabasterd/SpeedMeter.java b/src/main/java/com/tonikelope/megabasterd/SpeedMeter.java index b57ca537e..42868fcb3 100644 --- a/src/main/java/com/tonikelope/megabasterd/SpeedMeter.java +++ b/src/main/java/com/tonikelope/megabasterd/SpeedMeter.java @@ -18,7 +18,7 @@ import org.apache.commons.collections4.queue.CircularFifoQueue; public class SpeedMeter implements Runnable { public static final int SLEEP = 3000; - public static final int CHUNK_SPEED_QUEUE_MAX_SIZE = 10; + public static final int CHUNK_SPEED_QUEUE_MAX_SIZE = 20; private static final Logger LOG = Logger.getLogger(SpeedMeter.class.getName()); private final JLabel _speed_label; private final JLabel _rem_label; @@ -28,14 +28,14 @@ public class SpeedMeter implements Runnable { private long _speed_acumulator; private volatile long _max_avg_global_speed; private volatile long _avg_chunk_speed; - private final CircularFifoQueue _chunk_speed_queue; + private final CircularFifoQueue _pepillo_chunk_speed_queue; SpeedMeter(TransferenceManager trans_manager, JLabel sp_label, JLabel rem_label) { _speed_label = sp_label; _rem_label = rem_label; _trans_manager = trans_manager; _transferences = new ConcurrentHashMap<>(); - _chunk_speed_queue = new CircularFifoQueue(CHUNK_SPEED_QUEUE_MAX_SIZE); + _pepillo_chunk_speed_queue = new CircularFifoQueue(CHUNK_SPEED_QUEUE_MAX_SIZE); _speed_counter = 0L; _speed_acumulator = 0L; _max_avg_global_speed = 0L; @@ -56,22 +56,22 @@ public class SpeedMeter implements Runnable { public void update_avg_chunk_speed(long speed) { - synchronized (_chunk_speed_queue) { + synchronized (_pepillo_chunk_speed_queue) { - this._chunk_speed_queue.add(speed); + this._pepillo_chunk_speed_queue.add(speed); - if (_chunk_speed_queue.size() == _chunk_speed_queue.maxSize()) { + if (_pepillo_chunk_speed_queue.size() == _pepillo_chunk_speed_queue.maxSize()) { long acumulador = 0; - Iterator i = _chunk_speed_queue.iterator(); + Iterator i = _pepillo_chunk_speed_queue.iterator(); while (i.hasNext()) { acumulador += (long) i.next(); } - _avg_chunk_speed = Math.round(((double) acumulador) / _chunk_speed_queue.size()); + _avg_chunk_speed = Math.round(((double) acumulador) / _pepillo_chunk_speed_queue.size()); } } } diff --git a/src/main/resources/images/mbasterd_screen.png b/src/main/resources/images/mbasterd_screen.png index 013d3ac99..705acc156 100644 Binary files a/src/main/resources/images/mbasterd_screen.png and b/src/main/resources/images/mbasterd_screen.png differ