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;