core-3nweb-client-lib 0.53.8 → 0.53.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -59,6 +59,7 @@ export declare class Download {
|
|
|
59
59
|
private readonly downloader;
|
|
60
60
|
saveSegs?: ObjVersionFile["saveSegs"] | undefined;
|
|
61
61
|
segsNotInVersionFiles?: ObjOnDisk["segsNotInVersionFiles"] | undefined;
|
|
62
|
+
private downloadPrep;
|
|
62
63
|
private readonly segsAsapRequest;
|
|
63
64
|
private initDataRequest;
|
|
64
65
|
private inBkgrnd;
|
|
@@ -185,8 +185,8 @@ class ObjOnDisk {
|
|
|
185
185
|
thisVerOfs,
|
|
186
186
|
baseVerOfs
|
|
187
187
|
});
|
|
188
|
-
thisVerOfs += len;
|
|
189
|
-
baseVerOfs += len;
|
|
188
|
+
thisVerOfs += chunkFromBase.len;
|
|
189
|
+
baseVerOfs += chunkFromBase.len;
|
|
190
190
|
}
|
|
191
191
|
}
|
|
192
192
|
return segsInfo;
|
|
@@ -262,6 +262,7 @@ class Download {
|
|
|
262
262
|
this.downloader = downloader;
|
|
263
263
|
this.saveSegs = saveSegs;
|
|
264
264
|
this.segsNotInVersionFiles = segsNotInVersionFiles;
|
|
265
|
+
this.downloadPrep = undefined;
|
|
265
266
|
this.segsAsapRequest = [];
|
|
266
267
|
this.initDataRequest = undefined;
|
|
267
268
|
this.inBkgrnd = undefined;
|
|
@@ -304,32 +305,47 @@ class Download {
|
|
|
304
305
|
}
|
|
305
306
|
async downloadAllInBackground(eventSink) {
|
|
306
307
|
if (!this.segsNotInVersionFiles) {
|
|
307
|
-
throw new Error(`
|
|
308
|
+
throw new Error(`segsNotInVersionFiles is not initialized`);
|
|
308
309
|
}
|
|
309
310
|
if (this.inBkgrnd) {
|
|
310
311
|
return this.inBkgrnd.downloadTaskId;
|
|
311
312
|
}
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
return;
|
|
313
|
+
else if (this.downloadPrep) {
|
|
314
|
+
return this.downloadPrep.promise;
|
|
315
315
|
}
|
|
316
|
-
this.
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
316
|
+
this.downloadPrep = (0, deferred_1.defer)();
|
|
317
|
+
(async () => {
|
|
318
|
+
const chunks = await this.segsNotInVersionFiles();
|
|
319
|
+
if (chunks.length === 0) {
|
|
320
|
+
return;
|
|
321
|
+
}
|
|
322
|
+
this.inBkgrnd = {
|
|
323
|
+
downloadTaskId: Math.floor(Math.random() * Number.MAX_SAFE_INTEGER),
|
|
324
|
+
eventSink,
|
|
325
|
+
totalBytesToDownload: chunks.reduce((total, chunk) => (total + chunk.len), 0)
|
|
326
|
+
};
|
|
327
|
+
eventSink({
|
|
328
|
+
type: 'download-started',
|
|
329
|
+
downloadTaskId: this.inBkgrnd.downloadTaskId,
|
|
330
|
+
path: '',
|
|
331
|
+
version: this.version,
|
|
332
|
+
totalBytesToDownload: this.inBkgrnd.totalBytesToDownload
|
|
333
|
+
});
|
|
334
|
+
if (this.segsAsapRequest.length === 0) {
|
|
335
|
+
this.inBkgrnd.chunks = chunks;
|
|
336
|
+
}
|
|
337
|
+
this.downloader.schedule(this);
|
|
338
|
+
return this.inBkgrnd.downloadTaskId;
|
|
339
|
+
})().then(taskId => {
|
|
340
|
+
var _a;
|
|
341
|
+
(_a = this.downloadPrep) === null || _a === void 0 ? void 0 : _a.resolve(taskId);
|
|
342
|
+
this.downloadPrep = undefined;
|
|
343
|
+
}, err => {
|
|
344
|
+
var _a;
|
|
345
|
+
(_a = this.downloadPrep) === null || _a === void 0 ? void 0 : _a.reject(err);
|
|
346
|
+
this.downloadPrep = undefined;
|
|
327
347
|
});
|
|
328
|
-
|
|
329
|
-
this.inBkgrnd.chunks = chunks;
|
|
330
|
-
}
|
|
331
|
-
this.downloader.schedule(this);
|
|
332
|
-
return this.inBkgrnd.downloadTaskId;
|
|
348
|
+
return this.downloadPrep.promise;
|
|
333
349
|
}
|
|
334
350
|
nextActionType() {
|
|
335
351
|
if (this.initDataRequest) {
|