mirror of
https://github.com/tonikelope/megabasterd.git
synced 2025-04-29 22:24:32 +02:00
7.96
CHUNKWRITER joining chunks improving and bug fix MUST UPGRADE
This commit is contained in:
parent
754ae6a89f
commit
f54614badd
2
pom.xml
2
pom.xml
@ -3,7 +3,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.tonikelope</groupId>
|
||||
<artifactId>MegaBasterd</artifactId>
|
||||
<version>7.95</version>
|
||||
<version>7.96</version>
|
||||
<packaging>jar</packaging>
|
||||
<repositories>
|
||||
<repository>
|
||||
|
@ -143,7 +143,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_" + _download.getFile_key());
|
||||
File chunks_temp_dir = new File((_download.getCustom_chunks_dir() != null ? _download.getCustom_chunks_dir() : _download.getDownload_path()) + "/.MEGABASTERD_CHUNKS_" + MiscTools.HashString("sha1", _download.getUrl()));
|
||||
|
||||
chunks_temp_dir.mkdirs();
|
||||
|
||||
@ -159,6 +159,19 @@ public class ChunkWriterManager implements Runnable, SecureSingleThreadNotifiabl
|
||||
}
|
||||
}
|
||||
|
||||
private void finishDownload() {
|
||||
_download.getMain_panel().getDownload_manager().getTransference_running_list().remove(_download);
|
||||
_download.getMain_panel().getDownload_manager().secureNotify();
|
||||
_download.getView().printStatusNormal("Download finished. Joining file chunks, please wait...");
|
||||
_download.getView().getPause_button().setVisible(false);
|
||||
_download.getMain_panel().getGlobal_dl_speed().detachTransference(_download);
|
||||
_download.getView().getSpeed_label().setVisible(false);
|
||||
_download.getView().getSlots_label().setVisible(false);
|
||||
_download.getView().getSlot_status_label().setVisible(false);
|
||||
_download.getView().getSlots_spinner().setVisible(false);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
@ -170,23 +183,14 @@ public class ChunkWriterManager implements Runnable, SecureSingleThreadNotifiabl
|
||||
|
||||
if (!download_finished && _download.getProgress() == _file_size) {
|
||||
|
||||
_download.getMain_panel().getDownload_manager().getTransference_running_list().remove(_download);
|
||||
_download.getMain_panel().getDownload_manager().secureNotify();
|
||||
|
||||
_download.getView().printStatusNormal("Download finished. Joining file chunks, please wait...");
|
||||
_download.getView().getPause_button().setVisible(false);
|
||||
_download.getMain_panel().getGlobal_dl_speed().detachTransference(_download);
|
||||
_download.getView().getSpeed_label().setVisible(false);
|
||||
_download.getView().getSlots_label().setVisible(false);
|
||||
_download.getView().getSlot_status_label().setVisible(false);
|
||||
_download.getView().getSlots_spinner().setVisible(false);
|
||||
finishDownload();
|
||||
download_finished = true;
|
||||
}
|
||||
|
||||
boolean chunk_io_error;
|
||||
|
||||
do {
|
||||
synchronized (ChunkWriterManager.class) {
|
||||
|
||||
chunk_io_error = false;
|
||||
|
||||
try {
|
||||
@ -197,16 +201,7 @@ public class ChunkWriterManager implements Runnable, SecureSingleThreadNotifiabl
|
||||
|
||||
if (!download_finished && _download.getProgress() == _file_size) {
|
||||
|
||||
_download.getMain_panel().getDownload_manager().getTransference_running_list().remove(_download);
|
||||
_download.getMain_panel().getDownload_manager().secureNotify();
|
||||
|
||||
_download.getView().printStatusNormal("Download finished. Joining file chunks, please wait...");
|
||||
_download.getView().getPause_button().setVisible(false);
|
||||
_download.getMain_panel().getGlobal_dl_speed().detachTransference(_download);
|
||||
_download.getView().getSpeed_label().setVisible(false);
|
||||
_download.getView().getSlots_label().setVisible(false);
|
||||
_download.getView().getSlot_status_label().setVisible(false);
|
||||
_download.getView().getSlots_spinner().setVisible(false);
|
||||
finishDownload();
|
||||
download_finished = true;
|
||||
}
|
||||
|
||||
@ -230,7 +225,7 @@ public class ChunkWriterManager implements Runnable, SecureSingleThreadNotifiabl
|
||||
|
||||
chunk_file.delete();
|
||||
|
||||
chunk_file = new File(getChunks_dir() + "/" + new File(_download.getFile_name()).getName() + ".chunk" + String.valueOf(_last_chunk_id_written + 1));
|
||||
chunk_file = new File(getChunks_dir() + "/" + MiscTools.HashString("sha1", _download.getUrl()) + ".chunk" + String.valueOf(_last_chunk_id_written + 1));
|
||||
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
@ -238,14 +233,20 @@ public class ChunkWriterManager implements Runnable, SecureSingleThreadNotifiabl
|
||||
LOG.log(Level.WARNING, ex.getMessage());
|
||||
MiscTools.pausar(1000);
|
||||
}
|
||||
}
|
||||
|
||||
} while (chunk_io_error);
|
||||
|
||||
if (!_exit && (!_download.isStopped() || !_download.getChunkworkers().isEmpty()) && _bytes_written < _file_size) {
|
||||
|
||||
LOG.log(Level.INFO, "{0} ChunkWriterManager waiting for chunk [{1}] {2}...", new Object[]{Thread.currentThread().getName(), _last_chunk_id_written + 1, _download.getFile_name()});
|
||||
|
||||
secureWait();
|
||||
try {
|
||||
synchronized (_secure_notify_lock) {
|
||||
_secure_notify_lock.wait(1000);
|
||||
}
|
||||
} catch (InterruptedException ex) {
|
||||
Logger.getLogger(ChunkWriterManager.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -70,7 +70,7 @@ import javax.swing.UIManager;
|
||||
*/
|
||||
public final class MainPanel {
|
||||
|
||||
public static final String VERSION = "7.95";
|
||||
public static final String VERSION = "7.96";
|
||||
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 DEFAULT_BYTE_BUFFER_SIZE = 16 * 1024;
|
||||
|
@ -27,6 +27,7 @@ import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
@ -42,7 +43,7 @@ public final class SmartMegaProxyManager {
|
||||
|
||||
private static final Logger LOG = Logger.getLogger(SmartMegaProxyManager.class.getName());
|
||||
private volatile String _proxy_list_url;
|
||||
private final LinkedHashMap<String, Long[]> _proxy_list;
|
||||
private final ConcurrentHashMap<String, Long[]> _proxy_list;
|
||||
private static final HashMap<String, String> PROXY_LIST_AUTH = new HashMap<>();
|
||||
private final MainPanel _main_panel;
|
||||
private volatile int _ban_time;
|
||||
@ -63,12 +64,14 @@ public final class SmartMegaProxyManager {
|
||||
|
||||
public SmartMegaProxyManager(String proxy_list_url, MainPanel main_panel) {
|
||||
_proxy_list_url = (proxy_list_url != null && !"".equals(proxy_list_url)) ? proxy_list_url : DEFAULT_SMART_PROXY_URL;
|
||||
_proxy_list = new LinkedHashMap<>();
|
||||
_proxy_list = new ConcurrentHashMap<>();
|
||||
_main_panel = main_panel;
|
||||
|
||||
refreshSmartProxySettings();
|
||||
|
||||
THREAD_POOL.execute(() -> {
|
||||
refreshProxyList();
|
||||
});
|
||||
}
|
||||
|
||||
private synchronized int countBlockedProxies() {
|
||||
@ -191,14 +194,12 @@ public final class SmartMegaProxyManager {
|
||||
_proxy_list_url = null;
|
||||
}
|
||||
|
||||
THREAD_POOL.execute(() -> {
|
||||
refreshProxyList();
|
||||
});
|
||||
}
|
||||
|
||||
public void refreshProxyList() {
|
||||
|
||||
THREAD_POOL.execute(() -> {
|
||||
|
||||
synchronized (this) {
|
||||
public synchronized void refreshProxyList() {
|
||||
|
||||
String data;
|
||||
|
||||
@ -351,8 +352,6 @@ public final class SmartMegaProxyManager {
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 208 KiB After Width: | Height: | Size: 207 KiB |
Loading…
x
Reference in New Issue
Block a user