fix (chunked): progress calculation

issue:
1. create a 2MB file: dd if=/dev/zero of=testfile bs=1024 count=2048
2. size chunk to 1MB

what we see: progress up to 50%, then stop and jump to 100%
This commit is contained in:
MickaelK
2024-11-28 02:25:02 +11:00
parent 016afe6923
commit c556a404f7
+1 -1
View File
@@ -330,7 +330,7 @@ function workerImplFile({ error, progress, speed }) {
progress: (p) => {
const chunksAlreadyDownloaded = i * chunkSize;
const currentChunkDownloaded = p / 100 * (
i !== numberOfChunks - 1 ? chunkSize : _file.size % chunkSize
i !== numberOfChunks - 1 ? chunkSize : (_file.size % chunkSize) || chunkSize
);
progress(Math.floor(100 * (chunksAlreadyDownloaded + currentChunkDownloaded) / _file.size));
},