diff --git a/src/utils/upload.ts b/src/utils/upload.ts index 9924e9d..9540463 100644 --- a/src/utils/upload.ts +++ b/src/utils/upload.ts @@ -46,11 +46,12 @@ export function uploadZip({url, zipStream, zipSize, onProgress}: UploadProps): P const progressStream = createProgressStream(zipSize, (sent, total) => { const elapsedSeconds = (Date.now() - startTime) / 1000 + const speedMBps = elapsedSeconds < 0.001 ? 0 : sent / elapsedSeconds / 1024 / 1024 onProgress({ progress: total ? sent / total : 0, loadedBytes: sent, totalBytes: total, - speedMBps: sent / elapsedSeconds / 1024 / 1024, + speedMBps, elapsedSeconds, }) }, ON_PROGRESS_THROTTLE_MS) diff --git a/src/utils/zip.ts b/src/utils/zip.ts index 407f097..572e400 100644 --- a/src/utils/zip.ts +++ b/src/utils/zip.ts @@ -47,13 +47,14 @@ export async function createZip({files, outputPath, onProgress}: CreateZipProps) const progressStream = createProgressStream(estimatedZipSize, (written, total) => { const elapsedSeconds = (Date.now() - startTime) / 1000 + const speedMBps = elapsedSeconds < 0.001 ? 0 : written / elapsedSeconds / 1024 / 1024 onProgress({ progress: total ? Math.min(1, written / total) : 0, writtenBytes: written, estimatedTotalBytes: total, sourceTotalBytes: totalSourceSize, elapsedSeconds, - speedMBps: written / elapsedSeconds / 1024 / 1024, + speedMBps, }) }, ON_PROGRESS_THROTTLE_MS)