w-converhp 2.0.52 → 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.
@@ -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#line97">line 97</a>
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>retry</code></td>
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
+ &lt;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>輸入傳輸失敗重試次數整數,預設為10</p></td>
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
+ &lt;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 Sun May 18 2025 13:25:20 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
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>
@@ -82,7 +82,9 @@ import getFileXxHash from 'wsemi/src/getFileXxHash.mjs'
82
82
  * @param {String} [opt.tokenType='Bearer'] 輸入token類型字串,預設'Bearer'
83
83
  * @param {Integer} [opt.sizeSlice=1024*1024] 輸入切片上傳檔案之切片檔案大小整數,單位為Byte,預設為1024*1024
84
84
  * @param {Integer} [opt.timeout=5*60*1000] 輸入最長等待時間整數,單位ms,預設為5*60*1000、為5分鐘
85
- * @param {Integer} [opt.retry=10] 輸入傳輸失敗重試次數整數,預設為10
85
+ * @param {Integer} [opt.retryMain=3] 輸入主要控制器傳輸失敗重試次數整數,預設為3
86
+ * @param {Integer} [opt.retryUpload=10] 輸入切片上傳檔案傳輸失敗重試次數整數,預設為10
87
+ * @param {Integer} [opt.retryDownload=2] 輸入下載檔案傳輸失敗重試次數整數,預設為2
86
88
  * @returns {Object} 回傳事件物件,可使用函數execute、upload
87
89
  * @example
88
90
  *
@@ -190,10 +192,22 @@ function WConverhpClient(opt) {
190
192
  timeout = 5 * 60 * 1000 //5min
191
193
  }
192
194
 
193
- //retry
194
- let retry = get(opt, 'retry')
195
- if (!isp0int(retry)) {
196
- retry = 10
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
197
211
  }
198
212
 
199
213
  //env
@@ -289,6 +303,12 @@ function WConverhpClient(opt) {
289
303
  cbProgress = () => {}
290
304
  }
291
305
 
306
+ //retry
307
+ let retry = get(opt, 'retry')
308
+ if (!isp0int(retry)) {
309
+ retry = 1
310
+ }
311
+
292
312
  //urlUse
293
313
  let urlUse = getUrlUse(type)
294
314
 
@@ -672,6 +692,7 @@ function WConverhpClient(opt) {
672
692
 
673
693
  //sendPkg
674
694
  let sendPkg = async(type, data, cbProgress) => {
695
+ //主要為中心化控制器使用, 通過execute進行上下傳數據
675
696
 
676
697
  //bb
677
698
  let bb = null
@@ -691,7 +712,7 @@ function WConverhpClient(opt) {
691
712
  }
692
713
 
693
714
  //send
694
- let res = await send(type, bb, { dataType: 'blob', cbProgress })
715
+ let res = await send(type, bb, { dataType: 'blob', retry: retryMain, cbProgress }) //bbb
695
716
 
696
717
  return res
697
718
  }
@@ -778,7 +799,7 @@ function WConverhpClient(opt) {
778
799
 
779
800
  //send check-total-hash
780
801
  // console.log(`send check-total-hash...`)
781
- 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
782
803
  // console.log('resUpCkt', resUpCkt)
783
804
  // resUpCkt {
784
805
  // path: 'uploadTemp\\2429b7ef08ce6ba9',
@@ -847,7 +868,7 @@ function WConverhpClient(opt) {
847
868
 
848
869
  //send check-slices-hash
849
870
  // console.log(`send check-slices-hash...`)
850
- 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
851
872
  // console.log('resUpCks', resUpCks)
852
873
  // resUpCks {
853
874
  // slks: [
@@ -905,7 +926,8 @@ function WConverhpClient(opt) {
905
926
  // let dir = msg.m
906
927
  // if (dir === 'upload' &amp;&amp; perc === 100) {
907
928
  // }
908
- }
929
+ },
930
+ retry: retryUpload, //bbb
909
931
  })
910
932
  // console.log('resSl', resSl)
911
933
 
@@ -916,7 +938,7 @@ function WConverhpClient(opt) {
916
938
 
917
939
  //send merge-slices-push
918
940
  // console.log(`send merge-slices-push...`)
919
- 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
920
942
  // console.log('resUpMgp', resUpMgp)
921
943
 
922
944
  //checkMerging
@@ -931,7 +953,7 @@ function WConverhpClient(opt) {
931
953
 
932
954
  //send merge-slices-get
933
955
  // console.log(`send merge-slices-get...`)
934
- 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
935
957
  .then((res) => {
936
958
  // console.log('res', res)
937
959
  // res => {
@@ -1065,7 +1087,7 @@ function WConverhpClient(opt) {
1065
1087
 
1066
1088
  //send download
1067
1089
  let msg = { fileId }
1068
- let resMg = await send('download', msg, { ...opt, dataType: 'json', cbProgress })
1090
+ let resMg = await send('download', msg, { ...opt, dataType: 'json', retry: retryDownload, cbProgress }) //bbb
1069
1091
  // console.log('resMg', resMg)
1070
1092
 
1071
1093
  return resMg
@@ -1084,7 +1106,7 @@ function WConverhpClient(opt) {
1084
1106
 
1085
1107
  //send download-get-filename
1086
1108
  let msg = { fileId }
1087
- let resMg = await send('download-get-filename', msg, { dataType: 'json' })
1109
+ let resMg = await send('download-get-filename', msg, { dataType: 'json', retry: retryDownload }) //bbb
1088
1110
  // console.log('resMg', resMg)
1089
1111
 
1090
1112
  //filename
@@ -1142,7 +1164,7 @@ export default WConverhpClient
1142
1164
  <br class="clear">
1143
1165
 
1144
1166
  <footer>
1145
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Sun May 18 2025 13:25:20 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
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.
1146
1168
  </footer>
1147
1169
 
1148
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 Sun May 18 2025 13:25:20 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
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 Sun May 18 2025 13:25:20 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
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 Sun May 18 2025 13:25:20 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
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.52",
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.90"
10
+ "wsemi": "^1.7.92"
11
11
  },
12
12
  "devDependencies": {
13
13
  "form-data": "^4.0.2",
@@ -35,7 +35,9 @@ import getFileXxHash from 'wsemi/src/getFileXxHash.mjs'
35
35
  * @param {String} [opt.tokenType='Bearer'] 輸入token類型字串,預設'Bearer'
36
36
  * @param {Integer} [opt.sizeSlice=1024*1024] 輸入切片上傳檔案之切片檔案大小整數,單位為Byte,預設為1024*1024
37
37
  * @param {Integer} [opt.timeout=5*60*1000] 輸入最長等待時間整數,單位ms,預設為5*60*1000、為5分鐘
38
- * @param {Integer} [opt.retry=10] 輸入傳輸失敗重試次數整數,預設為10
38
+ * @param {Integer} [opt.retryMain=3] 輸入主要控制器傳輸失敗重試次數整數,預設為3
39
+ * @param {Integer} [opt.retryUpload=10] 輸入切片上傳檔案傳輸失敗重試次數整數,預設為10
40
+ * @param {Integer} [opt.retryDownload=2] 輸入下載檔案傳輸失敗重試次數整數,預設為2
39
41
  * @returns {Object} 回傳事件物件,可使用函數execute、upload
40
42
  * @example
41
43
  *
@@ -143,10 +145,22 @@ function WConverhpClient(opt) {
143
145
  timeout = 5 * 60 * 1000 //5min
144
146
  }
145
147
 
146
- //retry
147
- let retry = get(opt, 'retry')
148
- if (!isp0int(retry)) {
149
- retry = 10
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
150
164
  }
151
165
 
152
166
  //env
@@ -242,6 +256,12 @@ function WConverhpClient(opt) {
242
256
  cbProgress = () => {}
243
257
  }
244
258
 
259
+ //retry
260
+ let retry = get(opt, 'retry')
261
+ if (!isp0int(retry)) {
262
+ retry = 1
263
+ }
264
+
245
265
  //urlUse
246
266
  let urlUse = getUrlUse(type)
247
267
 
@@ -625,6 +645,7 @@ function WConverhpClient(opt) {
625
645
 
626
646
  //sendPkg
627
647
  let sendPkg = async(type, data, cbProgress) => {
648
+ //主要為中心化控制器使用, 通過execute進行上下傳數據
628
649
 
629
650
  //bb
630
651
  let bb = null
@@ -644,7 +665,7 @@ function WConverhpClient(opt) {
644
665
  }
645
666
 
646
667
  //send
647
- let res = await send(type, bb, { dataType: 'blob', cbProgress })
668
+ let res = await send(type, bb, { dataType: 'blob', retry: retryMain, cbProgress }) //bbb
648
669
 
649
670
  return res
650
671
  }
@@ -731,7 +752,7 @@ function WConverhpClient(opt) {
731
752
 
732
753
  //send check-total-hash
733
754
  // console.log(`send check-total-hash...`)
734
- 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
735
756
  // console.log('resUpCkt', resUpCkt)
736
757
  // resUpCkt {
737
758
  // path: 'uploadTemp\\2429b7ef08ce6ba9',
@@ -800,7 +821,7 @@ function WConverhpClient(opt) {
800
821
 
801
822
  //send check-slices-hash
802
823
  // console.log(`send check-slices-hash...`)
803
- 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
804
825
  // console.log('resUpCks', resUpCks)
805
826
  // resUpCks {
806
827
  // slks: [
@@ -858,7 +879,8 @@ function WConverhpClient(opt) {
858
879
  // let dir = msg.m
859
880
  // if (dir === 'upload' && perc === 100) {
860
881
  // }
861
- }
882
+ },
883
+ retry: retryUpload, //bbb
862
884
  })
863
885
  // console.log('resSl', resSl)
864
886
 
@@ -869,7 +891,7 @@ function WConverhpClient(opt) {
869
891
 
870
892
  //send merge-slices-push
871
893
  // console.log(`send merge-slices-push...`)
872
- 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
873
895
  // console.log('resUpMgp', resUpMgp)
874
896
 
875
897
  //checkMerging
@@ -884,7 +906,7 @@ function WConverhpClient(opt) {
884
906
 
885
907
  //send merge-slices-get
886
908
  // console.log(`send merge-slices-get...`)
887
- 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
888
910
  .then((res) => {
889
911
  // console.log('res', res)
890
912
  // res => {
@@ -1018,7 +1040,7 @@ function WConverhpClient(opt) {
1018
1040
 
1019
1041
  //send download
1020
1042
  let msg = { fileId }
1021
- let resMg = await send('download', msg, { ...opt, dataType: 'json', cbProgress })
1043
+ let resMg = await send('download', msg, { ...opt, dataType: 'json', retry: retryDownload, cbProgress }) //bbb
1022
1044
  // console.log('resMg', resMg)
1023
1045
 
1024
1046
  return resMg
@@ -1037,7 +1059,7 @@ function WConverhpClient(opt) {
1037
1059
 
1038
1060
  //send download-get-filename
1039
1061
  let msg = { fileId }
1040
- let resMg = await send('download-get-filename', msg, { dataType: 'json' })
1062
+ let resMg = await send('download-get-filename', msg, { dataType: 'json', retry: retryDownload }) //bbb
1041
1063
  // console.log('resMg', resMg)
1042
1064
 
1043
1065
  //filename
@@ -49,7 +49,8 @@ let checkTotalHash = async (fileSize, sizeSlice, fileHash, pathUploadTemp) => {
49
49
  _fileSize = stats.size
50
50
  }
51
51
  catch (err) {
52
- // console.log(err)
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
- console.log(err)
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