w-converhp 2.0.51 → 2.0.53
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.
- package/README.md +1 -1
- package/babel.config.js +4 -3
- package/dist/w-converhp-client.umd.js +2 -2
- package/dist/w-converhp-client.umd.js.map +1 -1
- package/docs/WConverhpClient.html +84 -4
- package/docs/WConverhpClient.mjs.html +39 -16
- package/docs/WConverhpServer.html +1 -1
- package/docs/WConverhpServer.mjs.html +1 -1
- package/docs/index.html +1 -1
- package/package.json +2 -2
- package/src/WConverhpClient.mjs +38 -15
- package/src/checkTotalHash.mjs +4 -2
- package/src/checkTotalHash.wk.umd.js +1 -1
- package/srv.mjs +1 -0
|
@@ -80,7 +80,7 @@
|
|
|
80
80
|
|
|
81
81
|
<dt class="tag-source">Source:</dt>
|
|
82
82
|
<dd class="tag-source"><ul class="dummy"><li>
|
|
83
|
-
<a href="WConverhpClient.mjs.html">WConverhpClient.mjs</a>, <a href="WConverhpClient.mjs.html#
|
|
83
|
+
<a href="WConverhpClient.mjs.html">WConverhpClient.mjs</a>, <a href="WConverhpClient.mjs.html#line99">line 99</a>
|
|
84
84
|
</li></ul></dd>
|
|
85
85
|
|
|
86
86
|
|
|
@@ -444,7 +444,47 @@
|
|
|
444
444
|
|
|
445
445
|
<tr>
|
|
446
446
|
|
|
447
|
-
<td class="name"><code>
|
|
447
|
+
<td class="name"><code>retryMain</code></td>
|
|
448
|
+
|
|
449
|
+
|
|
450
|
+
<td class="type">
|
|
451
|
+
|
|
452
|
+
|
|
453
|
+
<span class="param-type">Integer</span>
|
|
454
|
+
|
|
455
|
+
|
|
456
|
+
|
|
457
|
+
|
|
458
|
+
</td>
|
|
459
|
+
|
|
460
|
+
|
|
461
|
+
<td class="attributes">
|
|
462
|
+
|
|
463
|
+
<optional><br>
|
|
464
|
+
|
|
465
|
+
|
|
466
|
+
|
|
467
|
+
|
|
468
|
+
|
|
469
|
+
</td>
|
|
470
|
+
|
|
471
|
+
|
|
472
|
+
|
|
473
|
+
<td class="default">
|
|
474
|
+
|
|
475
|
+
<code>3</code>
|
|
476
|
+
|
|
477
|
+
</td>
|
|
478
|
+
|
|
479
|
+
|
|
480
|
+
<td class="description last"><p>輸入主要控制器傳輸失敗重試次數整數,預設為3</p></td>
|
|
481
|
+
</tr>
|
|
482
|
+
|
|
483
|
+
|
|
484
|
+
|
|
485
|
+
<tr>
|
|
486
|
+
|
|
487
|
+
<td class="name"><code>retryUpload</code></td>
|
|
448
488
|
|
|
449
489
|
|
|
450
490
|
<td class="type">
|
|
@@ -477,7 +517,47 @@
|
|
|
477
517
|
</td>
|
|
478
518
|
|
|
479
519
|
|
|
480
|
-
<td class="description last"><p
|
|
520
|
+
<td class="description last"><p>輸入切片上傳檔案傳輸失敗重試次數整數,預設為10</p></td>
|
|
521
|
+
</tr>
|
|
522
|
+
|
|
523
|
+
|
|
524
|
+
|
|
525
|
+
<tr>
|
|
526
|
+
|
|
527
|
+
<td class="name"><code>retryDownload</code></td>
|
|
528
|
+
|
|
529
|
+
|
|
530
|
+
<td class="type">
|
|
531
|
+
|
|
532
|
+
|
|
533
|
+
<span class="param-type">Integer</span>
|
|
534
|
+
|
|
535
|
+
|
|
536
|
+
|
|
537
|
+
|
|
538
|
+
</td>
|
|
539
|
+
|
|
540
|
+
|
|
541
|
+
<td class="attributes">
|
|
542
|
+
|
|
543
|
+
<optional><br>
|
|
544
|
+
|
|
545
|
+
|
|
546
|
+
|
|
547
|
+
|
|
548
|
+
|
|
549
|
+
</td>
|
|
550
|
+
|
|
551
|
+
|
|
552
|
+
|
|
553
|
+
<td class="default">
|
|
554
|
+
|
|
555
|
+
<code>2</code>
|
|
556
|
+
|
|
557
|
+
</td>
|
|
558
|
+
|
|
559
|
+
|
|
560
|
+
<td class="description last"><p>輸入下載檔案傳輸失敗重試次數整數,預設為2</p></td>
|
|
481
561
|
</tr>
|
|
482
562
|
|
|
483
563
|
|
|
@@ -569,7 +649,7 @@
|
|
|
569
649
|
<br class="clear">
|
|
570
650
|
|
|
571
651
|
<footer>
|
|
572
|
-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on
|
|
652
|
+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Thu May 29 2025 22:33:21 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
|
573
653
|
</footer>
|
|
574
654
|
|
|
575
655
|
<script>prettyPrint();</script>
|
|
@@ -47,6 +47,7 @@
|
|
|
47
47
|
<article>
|
|
48
48
|
<pre class="prettyprint source linenums"><code>import axios from 'axios'
|
|
49
49
|
import get from 'lodash-es/get.js'
|
|
50
|
+
import size from 'lodash-es/size.js'
|
|
50
51
|
import isWindow from 'wsemi/src/isWindow.mjs'
|
|
51
52
|
import evem from 'wsemi/src/evem.mjs'
|
|
52
53
|
import genPm from 'wsemi/src/genPm.mjs'
|
|
@@ -81,7 +82,9 @@ import getFileXxHash from 'wsemi/src/getFileXxHash.mjs'
|
|
|
81
82
|
* @param {String} [opt.tokenType='Bearer'] 輸入token類型字串,預設'Bearer'
|
|
82
83
|
* @param {Integer} [opt.sizeSlice=1024*1024] 輸入切片上傳檔案之切片檔案大小整數,單位為Byte,預設為1024*1024
|
|
83
84
|
* @param {Integer} [opt.timeout=5*60*1000] 輸入最長等待時間整數,單位ms,預設為5*60*1000、為5分鐘
|
|
84
|
-
* @param {Integer} [opt.
|
|
85
|
+
* @param {Integer} [opt.retryMain=3] 輸入主要控制器傳輸失敗重試次數整數,預設為3
|
|
86
|
+
* @param {Integer} [opt.retryUpload=10] 輸入切片上傳檔案傳輸失敗重試次數整數,預設為10
|
|
87
|
+
* @param {Integer} [opt.retryDownload=2] 輸入下載檔案傳輸失敗重試次數整數,預設為2
|
|
85
88
|
* @returns {Object} 回傳事件物件,可使用函數execute、upload
|
|
86
89
|
* @example
|
|
87
90
|
*
|
|
@@ -189,10 +192,22 @@ function WConverhpClient(opt) {
|
|
|
189
192
|
timeout = 5 * 60 * 1000 //5min
|
|
190
193
|
}
|
|
191
194
|
|
|
192
|
-
//
|
|
193
|
-
let
|
|
194
|
-
if (!isp0int(
|
|
195
|
-
|
|
195
|
+
//retryMain
|
|
196
|
+
let retryMain = get(opt, 'retryMain')
|
|
197
|
+
if (!isp0int(retryMain)) {
|
|
198
|
+
retryMain = 3
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
//retryUpload
|
|
202
|
+
let retryUpload = get(opt, 'retryUpload')
|
|
203
|
+
if (!isp0int(retryUpload)) {
|
|
204
|
+
retryUpload = 10
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
//retryDownload
|
|
208
|
+
let retryDownload = get(opt, 'retryDownload')
|
|
209
|
+
if (!isp0int(retryDownload)) {
|
|
210
|
+
retryDownload = 2
|
|
196
211
|
}
|
|
197
212
|
|
|
198
213
|
//env
|
|
@@ -288,6 +303,12 @@ function WConverhpClient(opt) {
|
|
|
288
303
|
cbProgress = () => {}
|
|
289
304
|
}
|
|
290
305
|
|
|
306
|
+
//retry
|
|
307
|
+
let retry = get(opt, 'retry')
|
|
308
|
+
if (!isp0int(retry)) {
|
|
309
|
+
retry = 1
|
|
310
|
+
}
|
|
311
|
+
|
|
291
312
|
//urlUse
|
|
292
313
|
let urlUse = getUrlUse(type)
|
|
293
314
|
|
|
@@ -671,6 +692,7 @@ function WConverhpClient(opt) {
|
|
|
671
692
|
|
|
672
693
|
//sendPkg
|
|
673
694
|
let sendPkg = async(type, data, cbProgress) => {
|
|
695
|
+
//主要為中心化控制器使用, 通過execute進行上下傳數據
|
|
674
696
|
|
|
675
697
|
//bb
|
|
676
698
|
let bb = null
|
|
@@ -690,7 +712,7 @@ function WConverhpClient(opt) {
|
|
|
690
712
|
}
|
|
691
713
|
|
|
692
714
|
//send
|
|
693
|
-
let res = await send(type, bb, { dataType: 'blob', cbProgress })
|
|
715
|
+
let res = await send(type, bb, { dataType: 'blob', retry: retryMain, cbProgress }) //bbb
|
|
694
716
|
|
|
695
717
|
return res
|
|
696
718
|
}
|
|
@@ -777,7 +799,7 @@ function WConverhpClient(opt) {
|
|
|
777
799
|
|
|
778
800
|
//send check-total-hash
|
|
779
801
|
// console.log(`send check-total-hash...`)
|
|
780
|
-
let resUpCkt = await send('upload-controller', { mode: 'check-total-hash', fileHash: fileTotalHash, filename: fileTotalName, fileSize: fileTotalSize }, { dataType: 'json' })
|
|
802
|
+
let resUpCkt = await send('upload-controller', { mode: 'check-total-hash', fileHash: fileTotalHash, filename: fileTotalName, fileSize: fileTotalSize }, { dataType: 'json', retry: retryUpload }) //bbb
|
|
781
803
|
// console.log('resUpCkt', resUpCkt)
|
|
782
804
|
// resUpCkt {
|
|
783
805
|
// path: 'uploadTemp\\2429b7ef08ce6ba9',
|
|
@@ -807,14 +829,14 @@ function WConverhpClient(opt) {
|
|
|
807
829
|
}
|
|
808
830
|
|
|
809
831
|
//針對伺服器上已有切片檔案計算hash與比對
|
|
810
|
-
if (resUpCkt.bSls
|
|
832
|
+
if (resUpCkt.bSls) {
|
|
811
833
|
// console.log('receive slks...', resUpCkt.slks[0], size(resUpCkt.slks))
|
|
812
834
|
|
|
813
835
|
//fileSliceHashs
|
|
814
836
|
let fileSliceHashs = []
|
|
815
837
|
// let n = Math.max(resUpCkt.slks.length, 1)
|
|
816
838
|
// let nr = Math.floor(n / 100)
|
|
817
|
-
for (let k = 0; k < resUpCkt.slks
|
|
839
|
+
for (let k = 0; k < size(resUpCkt.slks); k++) {
|
|
818
840
|
// if (k % nr === 0) {
|
|
819
841
|
// console.log(`calc hash for slices`, round(k / resUpCkt.slks.length * 100, 1), '%')
|
|
820
842
|
// }
|
|
@@ -846,7 +868,7 @@ function WConverhpClient(opt) {
|
|
|
846
868
|
|
|
847
869
|
//send check-slices-hash
|
|
848
870
|
// console.log(`send check-slices-hash...`)
|
|
849
|
-
let resUpCks = await send('upload-controller', { mode: 'check-slices-hash', fileHash: fileTotalHash, fileSliceHashs }, { dataType: 'json' })
|
|
871
|
+
let resUpCks = await send('upload-controller', { mode: 'check-slices-hash', fileHash: fileTotalHash, fileSliceHashs }, { dataType: 'json', retry: retryUpload }) //bbb
|
|
850
872
|
// console.log('resUpCks', resUpCks)
|
|
851
873
|
// resUpCks {
|
|
852
874
|
// slks: [
|
|
@@ -904,7 +926,8 @@ function WConverhpClient(opt) {
|
|
|
904
926
|
// let dir = msg.m
|
|
905
927
|
// if (dir === 'upload' && perc === 100) {
|
|
906
928
|
// }
|
|
907
|
-
}
|
|
929
|
+
},
|
|
930
|
+
retry: retryUpload, //bbb
|
|
908
931
|
})
|
|
909
932
|
// console.log('resSl', resSl)
|
|
910
933
|
|
|
@@ -915,7 +938,7 @@ function WConverhpClient(opt) {
|
|
|
915
938
|
|
|
916
939
|
//send merge-slices-push
|
|
917
940
|
// console.log(`send merge-slices-push...`)
|
|
918
|
-
let resUpMgp = await send('upload-controller', { mode: 'merge-slices-push', fileHash: fileTotalHash, chunkTotal }, { dataType: 'json' })
|
|
941
|
+
let resUpMgp = await send('upload-controller', { mode: 'merge-slices-push', fileHash: fileTotalHash, chunkTotal }, { dataType: 'json', retry: retryUpload }) //bbb
|
|
919
942
|
// console.log('resUpMgp', resUpMgp)
|
|
920
943
|
|
|
921
944
|
//checkMerging
|
|
@@ -930,7 +953,7 @@ function WConverhpClient(opt) {
|
|
|
930
953
|
|
|
931
954
|
//send merge-slices-get
|
|
932
955
|
// console.log(`send merge-slices-get...`)
|
|
933
|
-
send('upload-controller', { mode: 'merge-slices-get', fileHash: fileTotalHash, filename: fileTotalName, queueId }, { dataType: 'json' })
|
|
956
|
+
send('upload-controller', { mode: 'merge-slices-get', fileHash: fileTotalHash, filename: fileTotalName, queueId }, { dataType: 'json', retry: retryUpload }) //bbb
|
|
934
957
|
.then((res) => {
|
|
935
958
|
// console.log('res', res)
|
|
936
959
|
// res => {
|
|
@@ -1064,7 +1087,7 @@ function WConverhpClient(opt) {
|
|
|
1064
1087
|
|
|
1065
1088
|
//send download
|
|
1066
1089
|
let msg = { fileId }
|
|
1067
|
-
let resMg = await send('download', msg, { ...opt, dataType: 'json', cbProgress })
|
|
1090
|
+
let resMg = await send('download', msg, { ...opt, dataType: 'json', retry: retryDownload, cbProgress }) //bbb
|
|
1068
1091
|
// console.log('resMg', resMg)
|
|
1069
1092
|
|
|
1070
1093
|
return resMg
|
|
@@ -1083,7 +1106,7 @@ function WConverhpClient(opt) {
|
|
|
1083
1106
|
|
|
1084
1107
|
//send download-get-filename
|
|
1085
1108
|
let msg = { fileId }
|
|
1086
|
-
let resMg = await send('download-get-filename', msg, { dataType: 'json' })
|
|
1109
|
+
let resMg = await send('download-get-filename', msg, { dataType: 'json', retry: retryDownload }) //bbb
|
|
1087
1110
|
// console.log('resMg', resMg)
|
|
1088
1111
|
|
|
1089
1112
|
//filename
|
|
@@ -1141,7 +1164,7 @@ export default WConverhpClient
|
|
|
1141
1164
|
<br class="clear">
|
|
1142
1165
|
|
|
1143
1166
|
<footer>
|
|
1144
|
-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on
|
|
1167
|
+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Thu May 29 2025 22:33:21 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
|
1145
1168
|
</footer>
|
|
1146
1169
|
|
|
1147
1170
|
<script>prettyPrint();</script>
|
|
@@ -749,7 +749,7 @@
|
|
|
749
749
|
<br class="clear">
|
|
750
750
|
|
|
751
751
|
<footer>
|
|
752
|
-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on
|
|
752
|
+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Thu May 29 2025 22:33:21 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
|
753
753
|
</footer>
|
|
754
754
|
|
|
755
755
|
<script>prettyPrint();</script>
|
|
@@ -1485,7 +1485,7 @@ export default WConverhpServer
|
|
|
1485
1485
|
<br class="clear">
|
|
1486
1486
|
|
|
1487
1487
|
<footer>
|
|
1488
|
-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on
|
|
1488
|
+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Thu May 29 2025 22:33:21 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
|
1489
1489
|
</footer>
|
|
1490
1490
|
|
|
1491
1491
|
<script>prettyPrint();</script>
|
package/docs/index.html
CHANGED
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
<br class="clear">
|
|
72
72
|
|
|
73
73
|
<footer>
|
|
74
|
-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on
|
|
74
|
+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Thu May 29 2025 22:33:21 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
|
75
75
|
</footer>
|
|
76
76
|
|
|
77
77
|
<script>prettyPrint();</script>
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "w-converhp",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.53",
|
|
4
4
|
"main": "dist/w-converhp-server.umd.js",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@hapi/hapi": "^21.4.0",
|
|
7
7
|
"@hapi/inert": "^7.1.0",
|
|
8
8
|
"axios": "^1.9.0",
|
|
9
9
|
"lodash-es": "^4.17.21",
|
|
10
|
-
"wsemi": "^1.7.
|
|
10
|
+
"wsemi": "^1.7.92"
|
|
11
11
|
},
|
|
12
12
|
"devDependencies": {
|
|
13
13
|
"form-data": "^4.0.2",
|
package/src/WConverhpClient.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import axios from 'axios'
|
|
2
2
|
import get from 'lodash-es/get.js'
|
|
3
|
+
import size from 'lodash-es/size.js'
|
|
3
4
|
import isWindow from 'wsemi/src/isWindow.mjs'
|
|
4
5
|
import evem from 'wsemi/src/evem.mjs'
|
|
5
6
|
import genPm from 'wsemi/src/genPm.mjs'
|
|
@@ -34,7 +35,9 @@ import getFileXxHash from 'wsemi/src/getFileXxHash.mjs'
|
|
|
34
35
|
* @param {String} [opt.tokenType='Bearer'] 輸入token類型字串,預設'Bearer'
|
|
35
36
|
* @param {Integer} [opt.sizeSlice=1024*1024] 輸入切片上傳檔案之切片檔案大小整數,單位為Byte,預設為1024*1024
|
|
36
37
|
* @param {Integer} [opt.timeout=5*60*1000] 輸入最長等待時間整數,單位ms,預設為5*60*1000、為5分鐘
|
|
37
|
-
* @param {Integer} [opt.
|
|
38
|
+
* @param {Integer} [opt.retryMain=3] 輸入主要控制器傳輸失敗重試次數整數,預設為3
|
|
39
|
+
* @param {Integer} [opt.retryUpload=10] 輸入切片上傳檔案傳輸失敗重試次數整數,預設為10
|
|
40
|
+
* @param {Integer} [opt.retryDownload=2] 輸入下載檔案傳輸失敗重試次數整數,預設為2
|
|
38
41
|
* @returns {Object} 回傳事件物件,可使用函數execute、upload
|
|
39
42
|
* @example
|
|
40
43
|
*
|
|
@@ -142,10 +145,22 @@ function WConverhpClient(opt) {
|
|
|
142
145
|
timeout = 5 * 60 * 1000 //5min
|
|
143
146
|
}
|
|
144
147
|
|
|
145
|
-
//
|
|
146
|
-
let
|
|
147
|
-
if (!isp0int(
|
|
148
|
-
|
|
148
|
+
//retryMain
|
|
149
|
+
let retryMain = get(opt, 'retryMain')
|
|
150
|
+
if (!isp0int(retryMain)) {
|
|
151
|
+
retryMain = 3
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
//retryUpload
|
|
155
|
+
let retryUpload = get(opt, 'retryUpload')
|
|
156
|
+
if (!isp0int(retryUpload)) {
|
|
157
|
+
retryUpload = 10
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
//retryDownload
|
|
161
|
+
let retryDownload = get(opt, 'retryDownload')
|
|
162
|
+
if (!isp0int(retryDownload)) {
|
|
163
|
+
retryDownload = 2
|
|
149
164
|
}
|
|
150
165
|
|
|
151
166
|
//env
|
|
@@ -241,6 +256,12 @@ function WConverhpClient(opt) {
|
|
|
241
256
|
cbProgress = () => {}
|
|
242
257
|
}
|
|
243
258
|
|
|
259
|
+
//retry
|
|
260
|
+
let retry = get(opt, 'retry')
|
|
261
|
+
if (!isp0int(retry)) {
|
|
262
|
+
retry = 1
|
|
263
|
+
}
|
|
264
|
+
|
|
244
265
|
//urlUse
|
|
245
266
|
let urlUse = getUrlUse(type)
|
|
246
267
|
|
|
@@ -624,6 +645,7 @@ function WConverhpClient(opt) {
|
|
|
624
645
|
|
|
625
646
|
//sendPkg
|
|
626
647
|
let sendPkg = async(type, data, cbProgress) => {
|
|
648
|
+
//主要為中心化控制器使用, 通過execute進行上下傳數據
|
|
627
649
|
|
|
628
650
|
//bb
|
|
629
651
|
let bb = null
|
|
@@ -643,7 +665,7 @@ function WConverhpClient(opt) {
|
|
|
643
665
|
}
|
|
644
666
|
|
|
645
667
|
//send
|
|
646
|
-
let res = await send(type, bb, { dataType: 'blob', cbProgress })
|
|
668
|
+
let res = await send(type, bb, { dataType: 'blob', retry: retryMain, cbProgress }) //bbb
|
|
647
669
|
|
|
648
670
|
return res
|
|
649
671
|
}
|
|
@@ -730,7 +752,7 @@ function WConverhpClient(opt) {
|
|
|
730
752
|
|
|
731
753
|
//send check-total-hash
|
|
732
754
|
// console.log(`send check-total-hash...`)
|
|
733
|
-
let resUpCkt = await send('upload-controller', { mode: 'check-total-hash', fileHash: fileTotalHash, filename: fileTotalName, fileSize: fileTotalSize }, { dataType: 'json' })
|
|
755
|
+
let resUpCkt = await send('upload-controller', { mode: 'check-total-hash', fileHash: fileTotalHash, filename: fileTotalName, fileSize: fileTotalSize }, { dataType: 'json', retry: retryUpload }) //bbb
|
|
734
756
|
// console.log('resUpCkt', resUpCkt)
|
|
735
757
|
// resUpCkt {
|
|
736
758
|
// path: 'uploadTemp\\2429b7ef08ce6ba9',
|
|
@@ -760,14 +782,14 @@ function WConverhpClient(opt) {
|
|
|
760
782
|
}
|
|
761
783
|
|
|
762
784
|
//針對伺服器上已有切片檔案計算hash與比對
|
|
763
|
-
if (resUpCkt.bSls
|
|
785
|
+
if (resUpCkt.bSls) {
|
|
764
786
|
// console.log('receive slks...', resUpCkt.slks[0], size(resUpCkt.slks))
|
|
765
787
|
|
|
766
788
|
//fileSliceHashs
|
|
767
789
|
let fileSliceHashs = []
|
|
768
790
|
// let n = Math.max(resUpCkt.slks.length, 1)
|
|
769
791
|
// let nr = Math.floor(n / 100)
|
|
770
|
-
for (let k = 0; k < resUpCkt.slks
|
|
792
|
+
for (let k = 0; k < size(resUpCkt.slks); k++) {
|
|
771
793
|
// if (k % nr === 0) {
|
|
772
794
|
// console.log(`calc hash for slices`, round(k / resUpCkt.slks.length * 100, 1), '%')
|
|
773
795
|
// }
|
|
@@ -799,7 +821,7 @@ function WConverhpClient(opt) {
|
|
|
799
821
|
|
|
800
822
|
//send check-slices-hash
|
|
801
823
|
// console.log(`send check-slices-hash...`)
|
|
802
|
-
let resUpCks = await send('upload-controller', { mode: 'check-slices-hash', fileHash: fileTotalHash, fileSliceHashs }, { dataType: 'json' })
|
|
824
|
+
let resUpCks = await send('upload-controller', { mode: 'check-slices-hash', fileHash: fileTotalHash, fileSliceHashs }, { dataType: 'json', retry: retryUpload }) //bbb
|
|
803
825
|
// console.log('resUpCks', resUpCks)
|
|
804
826
|
// resUpCks {
|
|
805
827
|
// slks: [
|
|
@@ -857,7 +879,8 @@ function WConverhpClient(opt) {
|
|
|
857
879
|
// let dir = msg.m
|
|
858
880
|
// if (dir === 'upload' && perc === 100) {
|
|
859
881
|
// }
|
|
860
|
-
}
|
|
882
|
+
},
|
|
883
|
+
retry: retryUpload, //bbb
|
|
861
884
|
})
|
|
862
885
|
// console.log('resSl', resSl)
|
|
863
886
|
|
|
@@ -868,7 +891,7 @@ function WConverhpClient(opt) {
|
|
|
868
891
|
|
|
869
892
|
//send merge-slices-push
|
|
870
893
|
// console.log(`send merge-slices-push...`)
|
|
871
|
-
let resUpMgp = await send('upload-controller', { mode: 'merge-slices-push', fileHash: fileTotalHash, chunkTotal }, { dataType: 'json' })
|
|
894
|
+
let resUpMgp = await send('upload-controller', { mode: 'merge-slices-push', fileHash: fileTotalHash, chunkTotal }, { dataType: 'json', retry: retryUpload }) //bbb
|
|
872
895
|
// console.log('resUpMgp', resUpMgp)
|
|
873
896
|
|
|
874
897
|
//checkMerging
|
|
@@ -883,7 +906,7 @@ function WConverhpClient(opt) {
|
|
|
883
906
|
|
|
884
907
|
//send merge-slices-get
|
|
885
908
|
// console.log(`send merge-slices-get...`)
|
|
886
|
-
send('upload-controller', { mode: 'merge-slices-get', fileHash: fileTotalHash, filename: fileTotalName, queueId }, { dataType: 'json' })
|
|
909
|
+
send('upload-controller', { mode: 'merge-slices-get', fileHash: fileTotalHash, filename: fileTotalName, queueId }, { dataType: 'json', retry: retryUpload }) //bbb
|
|
887
910
|
.then((res) => {
|
|
888
911
|
// console.log('res', res)
|
|
889
912
|
// res => {
|
|
@@ -1017,7 +1040,7 @@ function WConverhpClient(opt) {
|
|
|
1017
1040
|
|
|
1018
1041
|
//send download
|
|
1019
1042
|
let msg = { fileId }
|
|
1020
|
-
let resMg = await send('download', msg, { ...opt, dataType: 'json', cbProgress })
|
|
1043
|
+
let resMg = await send('download', msg, { ...opt, dataType: 'json', retry: retryDownload, cbProgress }) //bbb
|
|
1021
1044
|
// console.log('resMg', resMg)
|
|
1022
1045
|
|
|
1023
1046
|
return resMg
|
|
@@ -1036,7 +1059,7 @@ function WConverhpClient(opt) {
|
|
|
1036
1059
|
|
|
1037
1060
|
//send download-get-filename
|
|
1038
1061
|
let msg = { fileId }
|
|
1039
|
-
let resMg = await send('download-get-filename', msg, { dataType: 'json' })
|
|
1062
|
+
let resMg = await send('download-get-filename', msg, { dataType: 'json', retry: retryDownload }) //bbb
|
|
1040
1063
|
// console.log('resMg', resMg)
|
|
1041
1064
|
|
|
1042
1065
|
//filename
|
package/src/checkTotalHash.mjs
CHANGED
|
@@ -49,7 +49,8 @@ let checkTotalHash = async (fileSize, sizeSlice, fileHash, pathUploadTemp) => {
|
|
|
49
49
|
_fileSize = stats.size
|
|
50
50
|
}
|
|
51
51
|
catch (err) {
|
|
52
|
-
|
|
52
|
+
//若是有檔案被佔用或鎖定、移動、被刪除等, 可能觸發EPERM: operation not permitted
|
|
53
|
+
console.log(`check total file size: fs.statSync(pathFile)`, pathFile, err)
|
|
53
54
|
}
|
|
54
55
|
|
|
55
56
|
//bAllSize
|
|
@@ -97,7 +98,8 @@ let checkTotalHash = async (fileSize, sizeSlice, fileHash, pathUploadTemp) => {
|
|
|
97
98
|
b2 = stats.size === sizeSlice
|
|
98
99
|
}
|
|
99
100
|
catch (err) {
|
|
100
|
-
|
|
101
|
+
//若是有檔案被佔用或鎖定、移動、被刪除等, 可能觸發EPERM: operation not permitted
|
|
102
|
+
console.log(`check each file size: fs.statSync(pathFile)`, v.path, err)
|
|
101
103
|
}
|
|
102
104
|
|
|
103
105
|
//b
|