mirror of
https://github.com/tonikelope/megabasterd.git
synced 2025-04-29 22:24:32 +02:00
6.79
- Fix https://github.com/tonikelope/megabasterd/issues/149 (.mb_chunks_FILE_KEY) - Fix Windows file names with TABS - PROGRESS WATCHDOG FOR ALL DOWNLOADS (not only SmartProxy) -> 120 secs
This commit is contained in:
parent
803a005efc
commit
815723c1c2
2
pom.xml
2
pom.xml
@ -3,7 +3,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.tonikelope</groupId>
|
||||
<artifactId>MegaBasterd</artifactId>
|
||||
<version>6.78</version>
|
||||
<version>6.79</version>
|
||||
<packaging>jar</packaging>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
|
@ -1,7 +1,6 @@
|
||||
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 +21,7 @@ import java.util.logging.Logger;
|
||||
*/
|
||||
public class ChunkDownloader implements Runnable, SecureSingleThreadNotifiable {
|
||||
|
||||
public static final double SLOW_PROXY_PERC = 0.3;
|
||||
public static final double SLOW_PROXY_PERC = 0.5;
|
||||
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;
|
||||
@ -328,28 +327,25 @@ public class ChunkDownloader implements Runnable, SecureSingleThreadNotifiable {
|
||||
|
||||
http_error = 0;
|
||||
|
||||
//Proxy speed benchmark
|
||||
/*
|
||||
|
||||
//Proxy speed benchmark (TO DO: change of strategy. Perform a MEGA speed test without proxies and compare the download speed of the chunks with SmartProxy with respect to this speed (with an adjustment coefficient) in order to know if the proxy is slow.).
|
||||
if (_current_smart_proxy != null && finish_chunk_time != -1) {
|
||||
|
||||
//Update average chunk download speed using SmartProxy
|
||||
long chunk_speed = Math.round(chunk_size / (((double) (finish_chunk_time - init_chunk_time - paused)) / 1000));
|
||||
|
||||
_download.getMain_panel().getGlobal_dl_speed().update_avg_chunk_speed(chunk_speed);
|
||||
long expected_chunk_speed = ( MEGA_DOWNLOAD_SPEED / CURRENT_MEGABASTERD_CHUNK_DOWNLOADERS_COUNT ) * SLOW_PROXY_PERC;
|
||||
|
||||
long avg_chunk_speed = _download.getMain_panel().getGlobal_dl_speed().getAvg_chunk_speed();
|
||||
if (chunk_speed < expected_chunk_speed) {
|
||||
|
||||
if (avg_chunk_speed != -1) {
|
||||
LOG.log(Level.INFO, "{0} Worker [{1}] WARNING -> PROXY {2} CHUNK DOWNLOAD SPEED: {3}/s SEEMS TO BE SLOW (expected is {4}/s) {4}", new Object[]{Thread.currentThread().getName(), _id, _current_smart_proxy, formatBytes(chunk_speed), formatBytes(expected_chunk_speed), _download.getFile_name()});
|
||||
|
||||
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()});
|
||||
|
||||
slow_proxy = true;
|
||||
}
|
||||
slow_proxy = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
*/
|
||||
if (!FORCE_SMART_PROXY) {
|
||||
_current_smart_proxy = null;
|
||||
}
|
||||
|
@ -134,7 +134,7 @@ public class ChunkWriterManager implements Runnable, SecureSingleThreadNotifiabl
|
||||
|
||||
private String _create_chunks_temp_dir() {
|
||||
|
||||
File chunks_temp_dir = new File((_download.getCustom_chunks_dir() != null ? _download.getCustom_chunks_dir() : _download.getDownload_path()) + "/.mb_chunks_" + new File(_download.getFile_name()).getName());
|
||||
File chunks_temp_dir = new File((_download.getCustom_chunks_dir() != null ? _download.getCustom_chunks_dir() : _download.getDownload_path()) + "/.mb_chunks_" + _download.getFile_key());
|
||||
|
||||
chunks_temp_dir.mkdirs();
|
||||
|
||||
|
@ -46,7 +46,7 @@ import javax.swing.JComponent;
|
||||
public class Download implements Transference, Runnable, SecureSingleThreadNotifiable {
|
||||
|
||||
public static final boolean VERIFY_CBC_MAC_DEFAULT = false;
|
||||
public static final int PROGRESS_WATCHDOG_TIMEOUT = 60;
|
||||
public static final int PROGRESS_WATCHDOG_TIMEOUT = 120;
|
||||
public static final boolean USE_SLOTS_DEFAULT = true;
|
||||
public static final int WORKERS_DEFAULT = 6;
|
||||
public static final boolean USE_MEGA_ACCOUNT_DOWN = false;
|
||||
@ -637,7 +637,7 @@ public class Download implements Transference, Runnable, SecureSingleThreadNotif
|
||||
|
||||
THREAD_POOL.execute(() -> {
|
||||
|
||||
//PROGRESS WATCHDOG If a download using SmartProxy remains more than 60 seconds without receiving data, we force fatal error in order to restart it.
|
||||
//PROGRESS WATCHDOG If a download remains more than PROGRESS_WATCHDOG_TIMEOUT seconds without receiving data, we force fatal error in order to restart it.
|
||||
LOG.log(Level.INFO, "{0} PROGRESS WATCHDOG HELLO!", Thread.currentThread().getName());
|
||||
|
||||
long last_progress, progress = getProgress();
|
||||
@ -655,11 +655,14 @@ public class Download implements Transference, Runnable, SecureSingleThreadNotif
|
||||
}
|
||||
}
|
||||
|
||||
} while (!isExit() && progress < getFile_size() && (!isTurbo() || isPaused() || progress > last_progress));
|
||||
} while (!isExit() && progress < getFile_size() && (isPaused() || progress > last_progress));
|
||||
|
||||
if (!isExit() && progress < getFile_size() && progress <= last_progress) {
|
||||
if (!isExit() && _status_error == null && progress < getFile_size() && progress <= last_progress) {
|
||||
stopDownloader("PROGRESS WATCHDOG TIMEOUT!");
|
||||
MainPanel.getProxy_manager().refreshProxyList(); //Force SmartProxy proxy list refresh
|
||||
|
||||
if (MainPanel.getProxy_manager() != null) {
|
||||
MainPanel.getProxy_manager().refreshProxyList(); //Force SmartProxy proxy list refresh
|
||||
}
|
||||
}
|
||||
|
||||
LOG.log(Level.INFO, "{0} PROGRESS WATCHDOG BYE BYE!", Thread.currentThread().getName());
|
||||
@ -831,16 +834,12 @@ public class Download implements Transference, Runnable, SecureSingleThreadNotif
|
||||
getView().printStatusNormal("Download CANCELED!");
|
||||
}
|
||||
|
||||
} catch (IOException ex) {
|
||||
|
||||
} catch (Exception ex) {
|
||||
_status_error = "I/O ERROR " + ex.getMessage();
|
||||
|
||||
getView().printStatusError(_status_error);
|
||||
|
||||
LOG.log(Level.SEVERE, ex.getMessage());
|
||||
|
||||
} catch (Exception ex) {
|
||||
LOG.log(Level.SEVERE, ex.getMessage());
|
||||
}
|
||||
|
||||
if (_file != null && !getView().isKeepTempFileSelected()) {
|
||||
|
@ -53,7 +53,7 @@ import javax.swing.UIManager;
|
||||
*/
|
||||
public final class MainPanel {
|
||||
|
||||
public static final String VERSION = "6.78";
|
||||
public static final String VERSION = "6.79";
|
||||
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;
|
||||
|
@ -736,12 +736,12 @@ public class MiscTools {
|
||||
|
||||
public static String cleanFilename(String filename) {
|
||||
|
||||
return (System.getProperty("os.name").toLowerCase().contains("win") ? filename.replaceAll("[<>:\"/\\\\\\|\\?\\*]+", "").replaceAll("[ \\.]{1,}/{1,}", "/") : filename).replaceAll("[\\.]{1,}$", "").trim();
|
||||
return (System.getProperty("os.name").toLowerCase().contains("win") ? filename.replaceAll("[<>:\"/\\\\\\|\\?\\*\t]+", "").replaceAll("[ \\.]{1,}/{1,}", "/") : filename).replaceAll("[\\.]{1,}$", "").trim();
|
||||
}
|
||||
|
||||
public static String cleanFilePath(String path) {
|
||||
|
||||
return !path.equals(".") ? ((System.getProperty("os.name").toLowerCase().contains("win") ? path.replaceAll("[<>:\"\\|\\?\\*]+", "").replaceAll("[ \\.]{1,}/{1,}", "/") : path).replaceAll("[\\.]{1,}$", "").trim()) : path;
|
||||
return !path.equals(".") ? ((System.getProperty("os.name").toLowerCase().contains("win") ? path.replaceAll("[<>:\"\\|\\?\\*\t]+", "").replaceAll("[ \\.]{1,}/{1,}", "/") : path).replaceAll("[\\.]{1,}$", "").trim()) : path;
|
||||
}
|
||||
|
||||
public static byte[] genRandomByteArray(int length) {
|
||||
|
@ -2,14 +2,12 @@ package com.tonikelope.megabasterd;
|
||||
|
||||
import static com.tonikelope.megabasterd.MiscTools.*;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import javax.swing.JLabel;
|
||||
import org.apache.commons.collections4.queue.CircularFifoQueue;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -27,55 +25,21 @@ public class SpeedMeter implements Runnable {
|
||||
private long _speed_counter;
|
||||
private long _speed_acumulator;
|
||||
private volatile long _max_avg_global_speed;
|
||||
private volatile long _avg_chunk_speed;
|
||||
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<>();
|
||||
_pepillo_chunk_speed_queue = new CircularFifoQueue(CHUNK_SPEED_QUEUE_MAX_SIZE);
|
||||
_speed_counter = 0L;
|
||||
_speed_acumulator = 0L;
|
||||
_max_avg_global_speed = 0L;
|
||||
_avg_chunk_speed = -1;
|
||||
}
|
||||
|
||||
private long _getAvgGlobalSpeed() {
|
||||
return Math.round((double) _speed_acumulator / _speed_counter);
|
||||
}
|
||||
|
||||
public void setAvg_chunk_speed(long _avg_chunk_speed) {
|
||||
this._avg_chunk_speed = _avg_chunk_speed;
|
||||
}
|
||||
|
||||
public long getAvg_chunk_speed() {
|
||||
return _avg_chunk_speed;
|
||||
}
|
||||
|
||||
public void update_avg_chunk_speed(long speed) {
|
||||
|
||||
synchronized (_pepillo_chunk_speed_queue) {
|
||||
|
||||
this._pepillo_chunk_speed_queue.add(speed);
|
||||
|
||||
if (_pepillo_chunk_speed_queue.size() == _pepillo_chunk_speed_queue.maxSize()) {
|
||||
|
||||
long acumulador = 0;
|
||||
|
||||
Iterator i = _pepillo_chunk_speed_queue.iterator();
|
||||
|
||||
while (i.hasNext()) {
|
||||
|
||||
acumulador += (long) i.next();
|
||||
}
|
||||
|
||||
_avg_chunk_speed = Math.round(((double) acumulador) / _pepillo_chunk_speed_queue.size());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void attachTransference(Transference transference) {
|
||||
|
||||
HashMap<String, Object> properties = new HashMap<>();
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 194 KiB After Width: | Height: | Size: 190 KiB |
Loading…
x
Reference in New Issue
Block a user