mirror of
https://github.com/tonikelope/megabasterd.git
synced 2025-05-29 13:00:15 +02:00
5.38
Resume download bug fix
This commit is contained in:
parent
a07bdccfc8
commit
3d78a1d212
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>5.37</version>
|
<version>5.38</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -286,7 +286,10 @@ public class ChunkDownloader implements Runnable, SecureSingleThreadNotifiable {
|
|||||||
|
|
||||||
fo.close();
|
fo.close();
|
||||||
|
|
||||||
chunk_file.renameTo(new File(_download.getDownload_path() + "/" + _download.getFile_name() + ".chunk" + chunk_id));
|
if (chunk_reads == chunk_size) {
|
||||||
|
chunk_file.renameTo(new File(_download.getDownload_path() + "/" + _download.getFile_name() + ".chunk" + chunk_id));
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
chunk_reads = chunk_size;
|
chunk_reads = chunk_size;
|
||||||
|
@ -54,6 +54,9 @@ public final class ChunkManager implements Runnable, SecureSingleThreadNotifiabl
|
|||||||
|
|
||||||
_bytes_written = _download.getProgress();
|
_bytes_written = _download.getProgress();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Logger.getLogger(getClass().getName()).log(Level.INFO, "{0} Chunkmanager hello LAST CHUNK WRITTEN -> [{1}] {2}...", new Object[]{Thread.currentThread().getName(), _last_chunk_id_written, _bytes_written});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -113,7 +116,7 @@ public final class ChunkManager implements Runnable, SecureSingleThreadNotifiabl
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
Logger.getLogger(getClass().getName()).log(Level.INFO, "{0} Filewriter: let''s do some work!", Thread.currentThread().getName());
|
Logger.getLogger(getClass().getName()).log(Level.INFO, "{0} Chunkmanager: let's do some work!", Thread.currentThread().getName());
|
||||||
|
|
||||||
if (_file_size > 0) {
|
if (_file_size > 0) {
|
||||||
while (!_exit && (!_download.isStopped() || !_download.getChunkworkers().isEmpty()) && _bytes_written < _file_size) {
|
while (!_exit && (!_download.isStopped() || !_download.getChunkworkers().isEmpty()) && _bytes_written < _file_size) {
|
||||||
@ -136,6 +139,8 @@ public final class ChunkManager implements Runnable, SecureSingleThreadNotifiabl
|
|||||||
|
|
||||||
_bytes_written += chunk_file.length();
|
_bytes_written += chunk_file.length();
|
||||||
|
|
||||||
|
Logger.getLogger(getClass().getName()).log(Level.INFO, "{0} Chunkmanager has written to disk chunk [{1}] {2} {3}...", new Object[]{Thread.currentThread().getName(), _last_chunk_id_written + 1, _bytes_written, calculateLastWrittenChunk(_bytes_written)});
|
||||||
|
|
||||||
_last_chunk_id_written++;
|
_last_chunk_id_written++;
|
||||||
|
|
||||||
chunk_file.delete();
|
chunk_file.delete();
|
||||||
@ -145,7 +150,7 @@ public final class ChunkManager implements Runnable, SecureSingleThreadNotifiabl
|
|||||||
|
|
||||||
if (!_exit && (!_download.isStopped() || !_download.getChunkworkers().isEmpty()) && _bytes_written < _file_size) {
|
if (!_exit && (!_download.isStopped() || !_download.getChunkworkers().isEmpty()) && _bytes_written < _file_size) {
|
||||||
|
|
||||||
Logger.getLogger(getClass().getName()).log(Level.INFO, "{0} Filewriter waiting for chunk [{1}]...", new Object[]{Thread.currentThread().getName(), _last_chunk_id_written + 1});
|
Logger.getLogger(getClass().getName()).log(Level.INFO, "{0} Chunkmanager waiting for chunk [{1}]...", new Object[]{Thread.currentThread().getName(), _last_chunk_id_written + 1});
|
||||||
|
|
||||||
secureWait();
|
secureWait();
|
||||||
|
|
||||||
@ -163,14 +168,14 @@ public final class ChunkManager implements Runnable, SecureSingleThreadNotifiabl
|
|||||||
|
|
||||||
_download.secureNotify();
|
_download.secureNotify();
|
||||||
|
|
||||||
Logger.getLogger(getClass().getName()).log(Level.INFO, "{0} Filewriter: bye bye{1}", new Object[]{Thread.currentThread().getName(), _download.getFile().getName()});
|
Logger.getLogger(getClass().getName()).log(Level.INFO, "{0} Chunkmanager: bye bye{1}", new Object[]{Thread.currentThread().getName(), _download.getFile().getName()});
|
||||||
}
|
}
|
||||||
|
|
||||||
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((float) (temp_file_size - 3584 * 1024) / (1024 * 1024 * (_download.isUse_slots() ? Download.CHUNK_SIZE_MULTI : 1)));
|
return 7 + (long) Math.floor((float) (temp_file_size - 3584 * 1024) / (1024 * 1024 * (_download.isUse_slots() ? Download.CHUNK_SIZE_MULTI : 1)));
|
||||||
} else {
|
} else {
|
||||||
int i = 0, tot = 0;
|
long i = 0, tot = 0;
|
||||||
|
|
||||||
while (tot < temp_file_size) {
|
while (tot < temp_file_size) {
|
||||||
i++;
|
i++;
|
||||||
|
@ -523,6 +523,9 @@ public final class Download implements Transference, Runnable, SecureSingleThrea
|
|||||||
long max_size = calculateMaxTempFileSize(_file.length());
|
long max_size = calculateMaxTempFileSize(_file.length());
|
||||||
|
|
||||||
if (max_size != _file.length()) {
|
if (max_size != _file.length()) {
|
||||||
|
|
||||||
|
Logger.getLogger(getClass().getName()).log(Level.INFO, "{0} Downloader truncating mctemp file {1} -> {2} ", new Object[]{Thread.currentThread().getName(), _file.length(), max_size});
|
||||||
|
|
||||||
getView().printStatusNormal("Truncating temp file...");
|
getView().printStatusNormal("Truncating temp file...");
|
||||||
|
|
||||||
try (FileChannel out_truncate = new FileOutputStream(filename + ".mctemp", true).getChannel()) {
|
try (FileChannel out_truncate = new FileOutputStream(filename + ".mctemp", true).getChannel()) {
|
||||||
@ -1353,7 +1356,7 @@ public final class Download implements Transference, Runnable, SecureSingleThrea
|
|||||||
|
|
||||||
return reminder == 0 ? size : (size - reminder);
|
return reminder == 0 ? size : (size - reminder);
|
||||||
} else {
|
} else {
|
||||||
int i = 0, tot = 0;
|
long i = 0, tot = 0;
|
||||||
|
|
||||||
while (tot < size) {
|
while (tot < size) {
|
||||||
i++;
|
i++;
|
||||||
|
@ -47,7 +47,7 @@ import java.io.File;
|
|||||||
*/
|
*/
|
||||||
public final class MainPanel {
|
public final class MainPanel {
|
||||||
|
|
||||||
public static final String VERSION = "5.37";
|
public static final String VERSION = "5.38";
|
||||||
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;
|
||||||
|
@ -1199,9 +1199,9 @@ public final class Upload implements Transference, Runnable, SecureSingleThreadN
|
|||||||
public long calculateLastUploadedChunk(long bytes_read) {
|
public long calculateLastUploadedChunk(long bytes_read) {
|
||||||
|
|
||||||
if (bytes_read > 3584 * 1024) {
|
if (bytes_read > 3584 * 1024) {
|
||||||
return 7 + (long) Math.ceil((float) (bytes_read - 3584 * 1024) / (1024 * 1024));
|
return 7 + (long) Math.ceil((float) (bytes_read - 3584 * 1024) / (1024 * 1024 * Upload.CHUNK_SIZE_MULTI));
|
||||||
} else {
|
} else {
|
||||||
int i = 0, tot = 0;
|
long i = 0, tot = 0;
|
||||||
|
|
||||||
while (tot < bytes_read) {
|
while (tot < bytes_read) {
|
||||||
i++;
|
i++;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user