mirror of
https://github.com/tonikelope/megabasterd.git
synced 2025-05-29 04:50:14 +02:00
5.64
-Chunkdownloader mono resume download fix
This commit is contained in:
parent
862d69b3ea
commit
80ad172bd5
2
pom.xml
2
pom.xml
@ -3,7 +3,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.tonikelope</groupId>
|
||||
<artifactId>MegaBasterd</artifactId>
|
||||
<version>5.63</version>
|
||||
<version>5.64</version>
|
||||
<packaging>jar</packaging>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
|
@ -290,10 +290,10 @@ public class ChunkDownloader implements Runnable, SecureSingleThreadNotifiable {
|
||||
|
||||
Logger.getLogger(getClass().getName()).log(Level.INFO, "{0} Worker [{1}] has RECOVERED PREVIOUS chunk [{2}]!", new Object[]{Thread.currentThread().getName(), _id, chunk_id});
|
||||
|
||||
reads = -1;
|
||||
|
||||
finish_chunk_time = -1;
|
||||
|
||||
chunk_reads = chunk_size;
|
||||
|
||||
_download.getPartialProgress().add(chunk_size);
|
||||
|
||||
_download.getProgress_meter().secureNotify();
|
||||
@ -301,7 +301,7 @@ public class ChunkDownloader implements Runnable, SecureSingleThreadNotifiable {
|
||||
}
|
||||
}
|
||||
|
||||
if (chunk_reads == chunk_size || reads == -1) {
|
||||
if (chunk_reads == chunk_size) {
|
||||
|
||||
Logger.getLogger(getClass().getName()).log(Level.INFO, "{0} Worker [{1}] has DOWNLOADED chunk [{2}]!", new Object[]{Thread.currentThread().getName(), _id, chunk_id});
|
||||
|
||||
@ -322,7 +322,7 @@ public class ChunkDownloader implements Runnable, SecureSingleThreadNotifiable {
|
||||
|
||||
_download.getChunkmanager().secureNotify();
|
||||
|
||||
if (current_smart_proxy != null && finish_chunk_time > 0) {
|
||||
if (current_smart_proxy != null && finish_chunk_time != -1) {
|
||||
|
||||
//Proxy speed benchmark
|
||||
long chunk_speed = Math.round(chunk_size / ((double) (finish_chunk_time - init_chunk_time - paused) / 1000));
|
||||
|
@ -161,7 +161,7 @@ public class ChunkDownloaderMono extends ChunkDownloader {
|
||||
|
||||
}
|
||||
|
||||
if (chunk_reads == chunk_size || reads == -1) {
|
||||
if (chunk_reads == chunk_size) {
|
||||
|
||||
bytes_downloaded += chunk_reads;
|
||||
|
||||
@ -176,12 +176,10 @@ public class ChunkDownloaderMono extends ChunkDownloader {
|
||||
|
||||
}
|
||||
|
||||
} catch (IOException ex) {
|
||||
} catch (IOException | InterruptedException ex) {
|
||||
|
||||
Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex);
|
||||
|
||||
} catch (InterruptedException ex) {
|
||||
Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex);
|
||||
} finally {
|
||||
|
||||
if (chunk_error) {
|
||||
|
@ -78,15 +78,13 @@ public final class ChunkManager implements Runnable, SecureSingleThreadNotifiabl
|
||||
_rejectedChunkIds = new ConcurrentLinkedQueue<>();
|
||||
|
||||
if (_download.getProgress() == 0) {
|
||||
_download.setLast_chunk_id_dispatched(0);
|
||||
|
||||
_last_chunk_id_written = 0;
|
||||
|
||||
_bytes_written = 0;
|
||||
} else {
|
||||
_last_chunk_id_written = calculateLastWrittenChunk(_download.getProgress());
|
||||
|
||||
_download.setLast_chunk_id_dispatched(_last_chunk_id_written);
|
||||
} else {
|
||||
_last_chunk_id_written = _download.getLast_chunk_id_dispatched();
|
||||
|
||||
_bytes_written = _download.getProgress();
|
||||
}
|
||||
@ -159,7 +157,7 @@ public final class ChunkManager implements Runnable, SecureSingleThreadNotifiabl
|
||||
|
||||
_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)});
|
||||
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, _download.calculateLastWrittenChunk(_bytes_written)});
|
||||
|
||||
_last_chunk_id_written++;
|
||||
|
||||
@ -191,19 +189,4 @@ public final class ChunkManager implements Runnable, SecureSingleThreadNotifiabl
|
||||
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) {
|
||||
if (temp_file_size > 3584 * 1024) {
|
||||
return 7 + (long) Math.floor((float) (temp_file_size - 3584 * 1024) / (1024 * 1024 * (_download.isUse_slots() ? Download.CHUNK_SIZE_MULTI : 1)));
|
||||
} else {
|
||||
long i = 0, tot = 0;
|
||||
|
||||
while (tot < temp_file_size) {
|
||||
i++;
|
||||
tot += i * 128 * 1024;
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -176,6 +176,25 @@ public final class Download implements Transference, Runnable, SecureSingleThrea
|
||||
|
||||
}
|
||||
|
||||
public long getLast_chunk_id_dispatched() {
|
||||
return _last_chunk_id_dispatched;
|
||||
}
|
||||
|
||||
public long calculateLastWrittenChunk(long temp_file_size) {
|
||||
if (temp_file_size > 3584 * 1024) {
|
||||
return 7 + (long) Math.floor((float) (temp_file_size - 3584 * 1024) / (1024 * 1024 * (this.isUse_slots() ? Download.CHUNK_SIZE_MULTI : 1)));
|
||||
} else {
|
||||
long i = 0, tot = 0;
|
||||
|
||||
while (tot < temp_file_size) {
|
||||
i++;
|
||||
tot += i * 128 * 1024;
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
public void enableProxyTurboMode() {
|
||||
|
||||
synchronized (_turbo_proxy_lock) {
|
||||
@ -531,6 +550,8 @@ public final class Download implements Transference, Runnable, SecureSingleThrea
|
||||
|
||||
_progress = _file.length();
|
||||
|
||||
_last_chunk_id_dispatched = calculateLastWrittenChunk(_progress);
|
||||
|
||||
getView().updateProgressBar(_progress, _progress_bar_rate);
|
||||
|
||||
} else {
|
||||
|
@ -47,7 +47,7 @@ import javax.swing.UIManager;
|
||||
*/
|
||||
public final class MainPanel {
|
||||
|
||||
public static final String VERSION = "5.63";
|
||||
public static final String VERSION = "5.64";
|
||||
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;
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 190 KiB After Width: | Height: | Size: 191 KiB |
Loading…
x
Reference in New Issue
Block a user