core-3nweb-client-lib 0.49.2 → 0.49.3
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.
|
@@ -154,8 +154,6 @@ class Delivery {
|
|
|
154
154
|
}
|
|
155
155
|
const attachments = common_1.Attachments.fromMsg(msgToSend);
|
|
156
156
|
const localMeta = opts === null || opts === void 0 ? void 0 : opts.localMeta;
|
|
157
|
-
// DEBUG console to help capturing a bug
|
|
158
|
-
console.log(`Sending msg with delivery id ${id} ${attachments ? `with attachments` : `without attachments`}`);
|
|
159
157
|
// save msg, in case delivery should be restarted
|
|
160
158
|
const msgFS = await this.makeFSForNewMsg(id);
|
|
161
159
|
const msg = await msg_1.Msg.forNew(id, msgFS, msgToSend, sender, recipients, this.r, attachments, localMeta, opts === null || opts === void 0 ? void 0 : opts.retryRecipient);
|
|
@@ -39,8 +39,7 @@ class WIP {
|
|
|
39
39
|
this.packer = undefined;
|
|
40
40
|
this.currentObjIndInMeta = 0;
|
|
41
41
|
this.currentObj = undefined;
|
|
42
|
-
this.doStateRecording =
|
|
43
|
-
(this.msg.progress.msgSize > MSG_SIZE_FOR_STATE_RECORDING);
|
|
42
|
+
this.doStateRecording = (this.msg.progress.msgSize > MSG_SIZE_FOR_STATE_RECORDING);
|
|
44
43
|
Object.seal(this);
|
|
45
44
|
}
|
|
46
45
|
/**
|
|
@@ -81,6 +80,7 @@ class WIP {
|
|
|
81
80
|
* or if this wip is done, undefined is returned.
|
|
82
81
|
*/
|
|
83
82
|
startNext() {
|
|
83
|
+
var _a, _b;
|
|
84
84
|
let proc = this.proc.latestTaskAtThisMoment();
|
|
85
85
|
if (proc) {
|
|
86
86
|
return;
|
|
@@ -102,9 +102,13 @@ class WIP {
|
|
|
102
102
|
proc = this.proc.addStarted(this.sendObjs());
|
|
103
103
|
}
|
|
104
104
|
else if (stage === "cancel") {
|
|
105
|
+
// DEBUG log
|
|
106
|
+
console.log(` canceled sending msgId: ${(_a = this.state.session) === null || _a === void 0 ? void 0 : _a.msgId}`);
|
|
105
107
|
return;
|
|
106
108
|
}
|
|
107
109
|
else if (stage === undefined) {
|
|
110
|
+
// DEBUG log
|
|
111
|
+
console.log(` done sending msgId: ${(_b = this.state.session) === null || _b === void 0 ? void 0 : _b.msgId}`);
|
|
108
112
|
return;
|
|
109
113
|
}
|
|
110
114
|
else {
|
|
@@ -256,8 +260,9 @@ class WIP {
|
|
|
256
260
|
throw new Error(`Message pack is not set.`);
|
|
257
261
|
}
|
|
258
262
|
this.state.session = await this.sender.sendMetadata(this.state.pack.meta);
|
|
259
|
-
|
|
260
|
-
|
|
263
|
+
// DEBUG log
|
|
264
|
+
console.log(`\n wip.sendMeta() returned with\n msgId: ${this.state.session.msgId}\n meta.objIds sent to server:`, this.state.pack.meta.objIds);
|
|
265
|
+
this.msg.progress.recipients[this.state.recipient].idOnDelivery = this.state.session.msgId;
|
|
261
266
|
if (this.state.stage !== "cancel") {
|
|
262
267
|
this.state.stage = "5-send-objs";
|
|
263
268
|
}
|
|
@@ -310,6 +315,9 @@ class WIP {
|
|
|
310
315
|
return { objId, upload, src };
|
|
311
316
|
}
|
|
312
317
|
async completeDelivery() {
|
|
318
|
+
var _a;
|
|
319
|
+
// DEBUG log
|
|
320
|
+
console.log(` wip.completeDelivery() msg ${!!((_a = this.state.session) === null || _a === void 0 ? void 0 : _a.msgId)}`);
|
|
313
321
|
await this.sender.completeDelivery();
|
|
314
322
|
this.updateInfo(0, true);
|
|
315
323
|
this.state.stage = undefined;
|
|
@@ -329,12 +337,17 @@ class WIP {
|
|
|
329
337
|
* completes sending, when no more sending is left.
|
|
330
338
|
*/
|
|
331
339
|
async sendObjs() {
|
|
340
|
+
var _a, _b, _c;
|
|
341
|
+
// DEBUG log
|
|
342
|
+
console.log(` wip.sendObjs(), msgId: ${(_a = this.state.session) === null || _a === void 0 ? void 0 : _a.msgId}, p 0, \n !!this.sender is ${!!this.sender}\n this.currentObj is ${(_b = this.currentObj) === null || _b === void 0 ? void 0 : _b.objId}`);
|
|
332
343
|
if (!this.sender) {
|
|
333
344
|
this.sender = await sender_1.MailSender.resume(this.msg.r.makeNet(), this.state.recipient, this.state.session);
|
|
334
345
|
}
|
|
335
346
|
// ensure there is an object to send, or complete delivery
|
|
336
347
|
if (!this.currentObj) {
|
|
337
348
|
this.currentObj = await this.getObjToSend();
|
|
349
|
+
// DEBUG log
|
|
350
|
+
console.log(` ... this.getObjToSend() sets currentObj to be ${(_c = this.currentObj) === null || _c === void 0 ? void 0 : _c.objId}`);
|
|
338
351
|
if (!this.currentObj) {
|
|
339
352
|
return this.completeDelivery();
|
|
340
353
|
}
|
|
@@ -362,6 +375,8 @@ class WIP {
|
|
|
362
375
|
* @param obj is a message object to send
|
|
363
376
|
*/
|
|
364
377
|
async firstObjSendingRequest(obj) {
|
|
378
|
+
// DEBUG log
|
|
379
|
+
console.log(` wip.firstObjSendingRequest() ${obj.objId}`);
|
|
365
380
|
// read from source
|
|
366
381
|
const header = await obj.src.readHeader();
|
|
367
382
|
const { size, isEndless } = await obj.src.segSrc.getSize();
|
|
@@ -393,6 +408,8 @@ class WIP {
|
|
|
393
408
|
obj.upload.header = buffer_utils_1.base64.pack(header);
|
|
394
409
|
}
|
|
395
410
|
this.updateInfo(header.length + segsChunk.length);
|
|
411
|
+
// DEBUG log
|
|
412
|
+
console.log(` ... ${obj.objId} 1st/single obj request send, isObjDone is ${isObjDone}`);
|
|
396
413
|
return isObjDone;
|
|
397
414
|
}
|
|
398
415
|
/**
|
|
@@ -402,12 +419,16 @@ class WIP {
|
|
|
402
419
|
* @param obj is a message object to send
|
|
403
420
|
*/
|
|
404
421
|
async followingObjSendingRequest(obj) {
|
|
422
|
+
// DEBUG log
|
|
423
|
+
console.log(` wip.followingObjSendingRequest() ${obj.objId}`);
|
|
405
424
|
// read from source
|
|
406
425
|
const segsSize = obj.upload.expectedSegsSize;
|
|
407
426
|
const chunk = await obj.src.segSrc.readNext(this.sender.maxChunkSize);
|
|
408
427
|
// return early, when there are no bytes
|
|
409
428
|
if (!chunk) {
|
|
410
429
|
await this.sender.sendObj(obj.objId, EMPTY_BYTE_ARR, undefined, { ofs: obj.upload.segsOffset, last: true });
|
|
430
|
+
// DEBUG log
|
|
431
|
+
console.log(` ... ${obj.objId} 2nd/following obj request has no more chunk to send, and completed sending obj`);
|
|
411
432
|
return true;
|
|
412
433
|
}
|
|
413
434
|
// check for an overrun
|
|
@@ -427,6 +448,8 @@ class WIP {
|
|
|
427
448
|
await this.sender.sendObj(obj.objId, chunk, undefined, opts);
|
|
428
449
|
obj.upload.segsOffset += chunk.length;
|
|
429
450
|
this.updateInfo(chunk.length);
|
|
451
|
+
// DEBUG log
|
|
452
|
+
console.log(` ... ${obj.objId} 2nd/following obj request sent ${chunk.length} bytes, isObjDone is ${isObjDone}`);
|
|
430
453
|
return isObjDone;
|
|
431
454
|
}
|
|
432
455
|
}
|
|
@@ -451,10 +451,6 @@ class MailSender {
|
|
|
451
451
|
}
|
|
452
452
|
}
|
|
453
453
|
else if (rep.status === api.msgObj.SC.ok) {
|
|
454
|
-
// DEBUG console to help capturing a bug
|
|
455
|
-
if ((fstReq === null || fstReq === void 0 ? void 0 : fstReq.last) || (followReq === null || followReq === void 0 ? void 0 : followReq.last)) {
|
|
456
|
-
console.log(`sent obj ${objId} within msg ${this.msgId}`);
|
|
457
|
-
}
|
|
458
454
|
// normal return
|
|
459
455
|
return;
|
|
460
456
|
}
|