mirror of
https://github.com/tonikelope/megabasterd.git
synced 2025-05-29 13:00:15 +02:00
2.16
-Chunk size 10MB
This commit is contained in:
parent
9b9f7afae8
commit
d3a6a03596
@ -15,8 +15,42 @@ public final class Chunk {
|
|||||||
private final long _size;
|
private final long _size;
|
||||||
private final ByteArrayOutputStream _data_os;
|
private final ByteArrayOutputStream _data_os;
|
||||||
private final String _url;
|
private final String _url;
|
||||||
|
private final int _size_multi;
|
||||||
|
|
||||||
|
public int getSize_multi() {
|
||||||
|
return _size_multi;
|
||||||
|
}
|
||||||
|
|
||||||
public Chunk(long id, long file_size, String file_url) throws ChunkInvalidIdException {
|
public Chunk(long id, long file_size, String file_url) throws ChunkInvalidIdException {
|
||||||
|
_size_multi = 1;
|
||||||
|
|
||||||
|
_id = id;
|
||||||
|
|
||||||
|
_offset = calculateOffset();
|
||||||
|
|
||||||
|
if (file_size > 0) {
|
||||||
|
if (_offset >= file_size) {
|
||||||
|
throw new ChunkInvalidIdException(valueOf(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
if (id > 1) {
|
||||||
|
|
||||||
|
throw new ChunkInvalidIdException(valueOf(id));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_size = calculateSize(file_size);
|
||||||
|
|
||||||
|
_url = file_url != null ? file_url + "/" + _offset + "-" + (_offset + _size - 1) : null;
|
||||||
|
|
||||||
|
_data_os = new ByteArrayOutputStream((int) _size);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Chunk(long id, long file_size, String file_url, int size_multi) throws ChunkInvalidIdException {
|
||||||
|
_size_multi = size_multi;
|
||||||
|
|
||||||
_id = id;
|
_id = id;
|
||||||
|
|
||||||
_offset = calculateOffset();
|
_offset = calculateOffset();
|
||||||
@ -66,7 +100,7 @@ public final class Chunk {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private long calculateSize(long file_size) {
|
private long calculateSize(long file_size) {
|
||||||
long chunk_size = (_id >= 1 && _id <= 7) ? _id * 128 * 1024 : 1024 * 1024;
|
long chunk_size = (_id >= 1 && _id <= 7) ? _id * 128 * 1024 : 1024 * 1024 * _size_multi;
|
||||||
|
|
||||||
if (_offset + chunk_size > file_size) {
|
if (_offset + chunk_size > file_size) {
|
||||||
chunk_size = file_size - _offset;
|
chunk_size = file_size - _offset;
|
||||||
@ -78,7 +112,7 @@ public final class Chunk {
|
|||||||
private long calculateOffset() {
|
private long calculateOffset() {
|
||||||
long[] offs = {0, 128, 384, 768, 1280, 1920, 2688};
|
long[] offs = {0, 128, 384, 768, 1280, 1920, 2688};
|
||||||
|
|
||||||
return (_id <= 7 ? offs[(int) _id - 1] : (3584 + (_id - 8) * 1024)) * 1024;
|
return (_id <= 7 ? offs[(int) _id - 1] : (3584 + (_id - 8) * 1024 * _size_multi)) * 1024;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -110,7 +110,7 @@ public class ChunkDownloader implements Runnable, SecureSingleThreadNotifiable {
|
|||||||
worker_url = _download.getDownloadUrlForWorker();
|
worker_url = _download.getDownloadUrlForWorker();
|
||||||
}
|
}
|
||||||
|
|
||||||
chunk = new Chunk(_download.nextChunkId(), _download.getFile_size(), worker_url);
|
chunk = new Chunk(_download.nextChunkId(), _download.getFile_size(), worker_url, Transference.CHUNK_SIZE_MULTI);
|
||||||
|
|
||||||
HttpGet httpget = new HttpGet(new URI(chunk.getUrl()));
|
HttpGet httpget = new HttpGet(new URI(chunk.getUrl()));
|
||||||
|
|
||||||
|
@ -119,7 +119,7 @@ public class ChunkUploader implements Runnable, SecureSingleThreadNotifiable {
|
|||||||
conta_error = 0;
|
conta_error = 0;
|
||||||
|
|
||||||
while (!_exit && !_upload.isStopped()) {
|
while (!_exit && !_upload.isStopped()) {
|
||||||
chunk = new Chunk(_upload.nextChunkId(), _upload.getFile_size(), worker_url);
|
chunk = new Chunk(_upload.nextChunkId(), _upload.getFile_size(), worker_url, Transference.CHUNK_SIZE_MULTI);
|
||||||
|
|
||||||
f.seek(chunk.getOffset());
|
f.seek(chunk.getOffset());
|
||||||
|
|
||||||
|
@ -152,7 +152,7 @@ public final class ChunkWriter implements Runnable, SecureSingleThreadNotifiable
|
|||||||
|
|
||||||
private long calculateLastWrittenChunk(long temp_file_size) {
|
private long calculateLastWrittenChunk(long temp_file_size) {
|
||||||
if (temp_file_size > 3584 * 1024) {
|
if (temp_file_size > 3584 * 1024) {
|
||||||
return 7 + (long) Math.ceil((temp_file_size - 3584 * 1024) / (1024 * 1024));
|
return 7 + (long) Math.ceil((temp_file_size - 3584 * 1024) / (1024 * 1024 * Transference.CHUNK_SIZE_MULTI));
|
||||||
} else {
|
} else {
|
||||||
int i = 0, tot = 0;
|
int i = 0, tot = 0;
|
||||||
|
|
||||||
|
@ -1162,7 +1162,7 @@ public final class Download implements Transference, Runnable, SecureSingleThrea
|
|||||||
|
|
||||||
public long calculateMaxTempFileSize(long size) {
|
public long calculateMaxTempFileSize(long size) {
|
||||||
if (size > 3584 * 1024) {
|
if (size > 3584 * 1024) {
|
||||||
long reminder = (size - 3584 * 1024) % (1024 * 1024);
|
long reminder = (size - 3584 * 1024) % (1024 * 1024 * Transference.CHUNK_SIZE_MULTI);
|
||||||
|
|
||||||
return reminder == 0 ? size : (size - reminder);
|
return reminder == 0 ? size : (size - reminder);
|
||||||
} else {
|
} else {
|
||||||
|
@ -59,7 +59,7 @@ import org.apache.http.auth.UsernamePasswordCredentials;
|
|||||||
*/
|
*/
|
||||||
public final class MainPanel {
|
public final class MainPanel {
|
||||||
|
|
||||||
public static final String VERSION = "2.15";
|
public static final String VERSION = "2.16";
|
||||||
public static final int THROTTLE_SLICE_SIZE = 16 * 1024;
|
public static final int THROTTLE_SLICE_SIZE = 16 * 1024;
|
||||||
public static final int STREAMER_PORT = 1337;
|
public static final int STREAMER_PORT = 1337;
|
||||||
public static final int WATCHDOG_PORT = 1338;
|
public static final int WATCHDOG_PORT = 1338;
|
||||||
|
@ -9,7 +9,7 @@ import java.util.regex.Matcher;
|
|||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* https://stackoverflow.com/users/6477541/sarvesh-agarwal
|
* Thanks to -> https://stackoverflow.com/users/6477541/sarvesh-agarwal
|
||||||
*/
|
*/
|
||||||
public class MegaProxyServer extends Thread {
|
public class MegaProxyServer extends Thread {
|
||||||
|
|
||||||
|
@ -293,7 +293,7 @@
|
|||||||
<Component class="javax.swing.JLabel" name="default_slots_down_label">
|
<Component class="javax.swing.JLabel" name="default_slots_down_label">
|
||||||
<Properties>
|
<Properties>
|
||||||
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
|
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
|
||||||
<Font name="Ubuntu" size="20" style="1"/>
|
<Font name="Ubuntu" size="20" style="0"/>
|
||||||
</Property>
|
</Property>
|
||||||
<Property name="text" type="java.lang.String" value="Default slots per file:"/>
|
<Property name="text" type="java.lang.String" value="Default slots per file:"/>
|
||||||
<Property name="doubleBuffered" type="boolean" value="true"/>
|
<Property name="doubleBuffered" type="boolean" value="true"/>
|
||||||
@ -325,7 +325,7 @@
|
|||||||
<Component class="javax.swing.JLabel" name="max_down_speed_label">
|
<Component class="javax.swing.JLabel" name="max_down_speed_label">
|
||||||
<Properties>
|
<Properties>
|
||||||
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
|
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
|
||||||
<Font name="Ubuntu" size="20" style="1"/>
|
<Font name="Ubuntu" size="20" style="0"/>
|
||||||
</Property>
|
</Property>
|
||||||
<Property name="text" type="java.lang.String" value="Max speed (KB/s):"/>
|
<Property name="text" type="java.lang.String" value="Max speed (KB/s):"/>
|
||||||
</Properties>
|
</Properties>
|
||||||
@ -418,7 +418,7 @@
|
|||||||
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
|
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
|
||||||
<Font name="Ubuntu" size="14" style="2"/>
|
<Font name="Ubuntu" size="14" style="2"/>
|
||||||
</Property>
|
</Property>
|
||||||
<Property name="text" type="java.lang.String" value="Note: you MUST OPEN this port in your router/firewall."/>
|
<Property name="text" type="java.lang.String" value="Note: you MUST "OPEN" this port in your router/firewall."/>
|
||||||
</Properties>
|
</Properties>
|
||||||
</Component>
|
</Component>
|
||||||
<Component class="javax.swing.JSpinner" name="megacrypter_reverse_port_spinner">
|
<Component class="javax.swing.JSpinner" name="megacrypter_reverse_port_spinner">
|
||||||
@ -516,7 +516,7 @@
|
|||||||
<Component class="javax.swing.JLabel" name="default_slots_up_label">
|
<Component class="javax.swing.JLabel" name="default_slots_up_label">
|
||||||
<Properties>
|
<Properties>
|
||||||
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
|
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
|
||||||
<Font name="Ubuntu" size="20" style="1"/>
|
<Font name="Ubuntu" size="20" style="0"/>
|
||||||
</Property>
|
</Property>
|
||||||
<Property name="text" type="java.lang.String" value="Default slots per file:"/>
|
<Property name="text" type="java.lang.String" value="Default slots per file:"/>
|
||||||
<Property name="doubleBuffered" type="boolean" value="true"/>
|
<Property name="doubleBuffered" type="boolean" value="true"/>
|
||||||
@ -565,7 +565,7 @@
|
|||||||
<Component class="javax.swing.JLabel" name="max_up_speed_label">
|
<Component class="javax.swing.JLabel" name="max_up_speed_label">
|
||||||
<Properties>
|
<Properties>
|
||||||
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
|
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
|
||||||
<Font name="Ubuntu" size="20" style="1"/>
|
<Font name="Ubuntu" size="20" style="0"/>
|
||||||
</Property>
|
</Property>
|
||||||
<Property name="text" type="java.lang.String" value="Max speed (KB/s):"/>
|
<Property name="text" type="java.lang.String" value="Max speed (KB/s):"/>
|
||||||
</Properties>
|
</Properties>
|
||||||
|
@ -585,7 +585,7 @@ public final class SettingsDialog extends javax.swing.JDialog {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
default_slots_down_label.setFont(new java.awt.Font("Ubuntu", 1, 20)); // NOI18N
|
default_slots_down_label.setFont(new java.awt.Font("Ubuntu", 0, 20)); // NOI18N
|
||||||
default_slots_down_label.setText("Default slots per file:");
|
default_slots_down_label.setText("Default slots per file:");
|
||||||
default_slots_down_label.setDoubleBuffered(true);
|
default_slots_down_label.setDoubleBuffered(true);
|
||||||
|
|
||||||
@ -606,7 +606,7 @@ public final class SettingsDialog extends javax.swing.JDialog {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
max_down_speed_label.setFont(new java.awt.Font("Ubuntu", 1, 20)); // NOI18N
|
max_down_speed_label.setFont(new java.awt.Font("Ubuntu", 0, 20)); // NOI18N
|
||||||
max_down_speed_label.setText("Max speed (KB/s):");
|
max_down_speed_label.setText("Max speed (KB/s):");
|
||||||
|
|
||||||
max_down_speed_spinner.setFont(new java.awt.Font("Ubuntu", 0, 20)); // NOI18N
|
max_down_speed_spinner.setFont(new java.awt.Font("Ubuntu", 0, 20)); // NOI18N
|
||||||
@ -641,7 +641,7 @@ public final class SettingsDialog extends javax.swing.JDialog {
|
|||||||
megacrypter_reverse_port_label.setText("TCP Port:");
|
megacrypter_reverse_port_label.setText("TCP Port:");
|
||||||
|
|
||||||
megacrypter_reverse_warning_label.setFont(new java.awt.Font("Ubuntu", 2, 14)); // NOI18N
|
megacrypter_reverse_warning_label.setFont(new java.awt.Font("Ubuntu", 2, 14)); // NOI18N
|
||||||
megacrypter_reverse_warning_label.setText("Note: you MUST OPEN this port in your router/firewall.");
|
megacrypter_reverse_warning_label.setText("Note: you MUST \"OPEN\" this port in your router/firewall.");
|
||||||
|
|
||||||
megacrypter_reverse_port_spinner.setFont(new java.awt.Font("Ubuntu", 0, 16)); // NOI18N
|
megacrypter_reverse_port_spinner.setFont(new java.awt.Font("Ubuntu", 0, 16)); // NOI18N
|
||||||
|
|
||||||
@ -756,7 +756,7 @@ public final class SettingsDialog extends javax.swing.JDialog {
|
|||||||
|
|
||||||
jTabbedPane1.addTab("Downloads", downloads_panel);
|
jTabbedPane1.addTab("Downloads", downloads_panel);
|
||||||
|
|
||||||
default_slots_up_label.setFont(new java.awt.Font("Ubuntu", 1, 20)); // NOI18N
|
default_slots_up_label.setFont(new java.awt.Font("Ubuntu", 0, 20)); // NOI18N
|
||||||
default_slots_up_label.setText("Default slots per file:");
|
default_slots_up_label.setText("Default slots per file:");
|
||||||
default_slots_up_label.setDoubleBuffered(true);
|
default_slots_up_label.setDoubleBuffered(true);
|
||||||
|
|
||||||
@ -780,7 +780,7 @@ public final class SettingsDialog extends javax.swing.JDialog {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
max_up_speed_label.setFont(new java.awt.Font("Ubuntu", 1, 20)); // NOI18N
|
max_up_speed_label.setFont(new java.awt.Font("Ubuntu", 0, 20)); // NOI18N
|
||||||
max_up_speed_label.setText("Max speed (KB/s):");
|
max_up_speed_label.setText("Max speed (KB/s):");
|
||||||
|
|
||||||
max_up_speed_spinner.setFont(new java.awt.Font("Ubuntu", 0, 20)); // NOI18N
|
max_up_speed_spinner.setFont(new java.awt.Font("Ubuntu", 0, 20)); // NOI18N
|
||||||
|
@ -15,6 +15,7 @@ public interface Transference {
|
|||||||
boolean LIMIT_TRANSFERENCE_SPEED_DEFAULT = false;
|
boolean LIMIT_TRANSFERENCE_SPEED_DEFAULT = false;
|
||||||
int MAX_TRANSFERENCE_SPEED_DEFAULT = 5;
|
int MAX_TRANSFERENCE_SPEED_DEFAULT = 5;
|
||||||
int MAX_WAIT_WORKERS_SHUTDOWN = 15;
|
int MAX_WAIT_WORKERS_SHUTDOWN = 15;
|
||||||
|
int CHUNK_SIZE_MULTI = 10;
|
||||||
Integer[] FATAL_ERROR_API_CODES = {-2, -8, -9, -10, -11, -12, -13, -14, -15, -16, 22, 23, 24, 25};
|
Integer[] FATAL_ERROR_API_CODES = {-2, -8, -9, -10, -11, -12, -13, -14, -15, -16, 22, 23, 24, 25};
|
||||||
|
|
||||||
void start();
|
void start();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user