From 699da948e5e27ca98349e1994b4a26d1da00b976 Mon Sep 17 00:00:00 2001 From: Eduard Kuzmenko Date: Fri, 23 Jul 2021 18:38:11 +0300 Subject: [PATCH] Fix clearing download queue on cancel --- src/lib/mtproto/apiFileManager.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/lib/mtproto/apiFileManager.ts b/src/lib/mtproto/apiFileManager.ts index b2239532..bfe5f9d5 100644 --- a/src/lib/mtproto/apiFileManager.ts +++ b/src/lib/mtproto/apiFileManager.ts @@ -145,7 +145,7 @@ export class ApiFileManager { const activeDelta = data.activeDelta || 1; this.downloadActives[dcId] += activeDelta; - + data.cb() .then((result) => { this.downloadActives[dcId] -= activeDelta; @@ -190,11 +190,11 @@ export class ApiFileManager { } public requestFilePart(dcId: DcId, location: InputFileLocation, offset: number, limit: number, id = 0, queueId = 0, checkCancel?: () => void) { - return this.downloadRequest(dcId, id, () => { + return this.downloadRequest(dcId, id, async() => { // do not remove async, because checkCancel will throw an error checkCancel && checkCancel(); - const invoke = (): Promise => { - checkCancel && checkCancel(); + const invoke = async(): Promise => { + checkCancel && checkCancel(); // do not remove async, because checkCancel will throw an error const promise = apiManager.invokeApi('upload.getFile', { location,