Browse Source

Fix clearing download queue on cancel

master
Eduard Kuzmenko 3 years ago
parent
commit
699da948e5
  1. 8
      src/lib/mtproto/apiFileManager.ts

8
src/lib/mtproto/apiFileManager.ts

@ -145,7 +145,7 @@ export class ApiFileManager {
const activeDelta = data.activeDelta || 1; const activeDelta = data.activeDelta || 1;
this.downloadActives[dcId] += activeDelta; this.downloadActives[dcId] += activeDelta;
data.cb() data.cb()
.then((result) => { .then((result) => {
this.downloadActives[dcId] -= activeDelta; 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) { 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(); checkCancel && checkCancel();
const invoke = (): Promise<MyUploadFile> => { const invoke = async(): Promise<MyUploadFile> => {
checkCancel && checkCancel(); checkCancel && checkCancel(); // do not remove async, because checkCancel will throw an error
const promise = apiManager.invokeApi('upload.getFile', { const promise = apiManager.invokeApi('upload.getFile', {
location, location,

Loading…
Cancel
Save