From 7db1921823604864adfc095e06ecfab8c9c5929c Mon Sep 17 00:00:00 2001 From: liyu Date: Mon, 12 Aug 2024 01:52:48 +0800 Subject: [PATCH] fix: download progress callback (#709) * fix(type): progress callback defination * fix: downloaded progress --- gramjs/client/downloads.ts | 2 +- gramjs/define.d.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/gramjs/client/downloads.ts b/gramjs/client/downloads.ts index 63c07de0..3e10bc16 100644 --- a/gramjs/client/downloads.ts +++ b/gramjs/client/downloads.ts @@ -430,13 +430,13 @@ export async function downloadFileV2( msgData: msgData, })) { await writer.write(chunk); + downloaded = downloaded.add(chunk.length); if (progressCallback) { await progressCallback( downloaded, bigInt(fileSize || bigInt.zero) ); } - downloaded = downloaded.add(chunk.length); } return returnWriterValue(writer); } finally { diff --git a/gramjs/define.d.ts b/gramjs/define.d.ts index fad04ce1..5b00886f 100644 --- a/gramjs/define.d.ts +++ b/gramjs/define.d.ts @@ -64,8 +64,8 @@ type OutFile = | WriteStream | { write: Function; close?: Function }; type ProgressCallback = ( - total: bigInt.BigInteger, - downloaded: bigInt.BigInteger + downloaded: bigInt.BigInteger, + total: bigInt.BigInteger ) => void; type ButtonLike = Api.TypeKeyboardButton | Button;