Browse Source

Fix downloading patterns

master
Eduard Kuzmenko 2 years ago committed by r4sas
parent
commit
7735e12e36
  1. 13
      src/lib/mtproto/apiFileManager.ts

13
src/lib/mtproto/apiFileManager.ts

@ -698,6 +698,12 @@ export class ApiFileManager extends AppManager { @@ -698,6 +698,12 @@ export class ApiFileManager extends AppManager {
// downloadId && this.log('write time', performance.now() - perf, 'request time', requestTime, 'queue time', writeQueueTime);
}
if(isFinal) {
if(!size || done < size) {
prepared.forEach(({writer}) => writer?.trim?.(done));
}
}
if(isFinal && process) {
const promises = prepared
.filter(({writer}) => writer?.getParts && writer.replaceParts)
@ -714,12 +720,7 @@ export class ApiFileManager extends AppManager { @@ -714,12 +720,7 @@ export class ApiFileManager extends AppManager {
writeDeferred.resolve();
if(isFinal) {
const realSize = size || byteLength;
if(!size || byteLength < size) {
prepared.forEach(({writer}) => writer?.trim?.(realSize));
}
const saveToStorage = realSize <= MAX_FILE_SAVE_SIZE;
const saveToStorage = done <= MAX_FILE_SAVE_SIZE;
prepared.forEach((item) => {
const {deferred, writer} = item;
if(deferred.isFulfilled || deferred.isRejected || !writer) {

Loading…
Cancel
Save