w-converhp 2.0.35 → 2.0.37

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.
@@ -529,7 +529,7 @@
529
529
  <br class="clear">
530
530
 
531
531
  <footer>
532
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Mon Apr 14 2025 15:34:24 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
532
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Tue Apr 15 2025 14:44:02 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
533
533
  </footer>
534
534
 
535
535
  <script>prettyPrint();</script>
@@ -211,12 +211,12 @@ function WConverhpClient(opt) {
211
211
  else if (type === 'slice') {
212
212
  urlUse = `${url}slc`
213
213
  }
214
- else if (type === 'upload-check') {
215
- urlUse = `${url}ulck`
216
- }
217
- else if (type === 'slice-merge') {
218
- urlUse = `${url}slcm`
214
+ else if (type === 'upload-controller') {
215
+ urlUse = `${url}ulctr`
219
216
  }
217
+ // else if (type === 'slice-merge') {
218
+ // urlUse = `${url}slcm`
219
+ // }
220
220
  else if (type === 'download-get-filename') {
221
221
  urlUse = `${url}dwgfn`
222
222
  }
@@ -729,11 +729,11 @@ function WConverhpClient(opt) {
729
729
  let fileTotalHash = await calcHash(bb)
730
730
  // console.log(`calc hash for fileTotalSize[${fileTotalSize}] done`, fileTotalHash)
731
731
 
732
- //send upload-check
732
+ //send check-total-hash
733
733
  // console.log(`send check-total-hash...`)
734
- let resCk = await send('upload-check', { mode: 'check-total-hash', fileHash: fileTotalHash, fileSize: fileTotalSize }, { dataType: 'json' })
735
- // console.log('resCk', resCk)
736
- // resCk {
734
+ let resUpCkt = await send('upload-controller', { mode: 'check-total-hash', fileHash: fileTotalHash, filename: fileTotalName, fileSize: fileTotalSize }, { dataType: 'json' })
735
+ // console.log('resUpCkt', resUpCkt)
736
+ // resUpCkt {
737
737
  // path: 'uploadTemp\\2429b7ef08ce6ba9',
738
738
  // bAllExist: false,
739
739
  // bAllSize: false,
@@ -749,30 +749,30 @@ function WConverhpClient(opt) {
749
749
  // }
750
750
 
751
751
  //check
752
- if (resCk.bAllHash) {
752
+ if (resUpCkt.bAllHash) {
753
753
  // console.log('已有上傳大檔')
754
754
  let resMg = {
755
755
  filename: fileTotalName,
756
- path: resCk.path,
756
+ path: resUpCkt.path,
757
757
  }
758
758
  return resMg
759
759
  }
760
760
 
761
761
  //針對伺服器上已有切片檔案計算hash與比對
762
- if (resCk.slks.length > 0) {
763
- // console.log('receive slks...', resCk.slks[0], size(resCk.slks))
762
+ if (resUpCkt.slks.length > 0) {
763
+ // console.log('receive slks...', resUpCkt.slks[0], size(resUpCkt.slks))
764
764
 
765
765
  //fileSliceHashs
766
766
  let fileSliceHashs = []
767
- // let n = Math.max(resCk.slks.length, 1)
768
- // let nr = Math.floor(n / 200)
769
- for (let k = 0; k &lt; resCk.slks.length; k++) {
767
+ // let n = Math.max(resUpCkt.slks.length, 1)
768
+ // let nr = Math.floor(n / 100)
769
+ for (let k = 0; k &lt; resUpCkt.slks.length; k++) {
770
770
  // if (k % nr === 0) {
771
- // console.log(`calc hash for slices`, round(k / resCk.slks.length * 100, 1), '%')
771
+ // console.log(`calc hash for slices`, round(k / resUpCkt.slks.length * 100, 1), '%')
772
772
  // }
773
773
 
774
774
  //i
775
- let i = resCk.slks[k]
775
+ let i = resUpCkt.slks[k]
776
776
 
777
777
  //start
778
778
  let start = i * sizeSlice
@@ -796,11 +796,11 @@ function WConverhpClient(opt) {
796
796
  }
797
797
  // console.log('fileSliceHashs', fileSliceHashs)
798
798
 
799
- //send upload-check
799
+ //send check-slices-hash
800
800
  // console.log(`send check-slices-hash...`)
801
- let resCks = await send('upload-check', { mode: 'check-slices-hash', fileHash: fileTotalHash, fileSliceHashs }, { dataType: 'json' })
802
- // console.log('resCks', resCks)
803
- // resCks {
801
+ let resUpCks = await send('upload-controller', { mode: 'check-slices-hash', fileHash: fileTotalHash, fileSliceHashs }, { dataType: 'json' })
802
+ // console.log('resUpCks', resUpCks)
803
+ // resUpCks {
804
804
  // slks: [
805
805
  // 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
806
806
  // 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
@@ -810,8 +810,8 @@ function WConverhpClient(opt) {
810
810
  // ]
811
811
  // }
812
812
 
813
- //update
814
- resCk.slks = resCks.slks
813
+ //update, 伺服器針對各切片計算hash與比對, 回傳resUpCks.slks代表hash一致的切片編號, 非一致hash的切片則須重傳, 尚未傳切片亦須繼續傳
814
+ resUpCkt.slks = resUpCks.slks
815
815
 
816
816
  }
817
817
 
@@ -851,7 +851,7 @@ function WConverhpClient(opt) {
851
851
  for (let i = 0; i &lt; chunkTotal; i++) {
852
852
 
853
853
  //check
854
- if (resCk.slks.indexOf(i) >= 0) {
854
+ if (resUpCkt.slks.indexOf(i) >= 0) {
855
855
  // console.log('已有上傳切片檔')
856
856
  cbProgressSlice({ prog: 100, m: 'upload' }) //直接觸發更新進度
857
857
  continue
@@ -867,7 +867,7 @@ function WConverhpClient(opt) {
867
867
  let chunk = bb.slice(start, end)
868
868
 
869
869
  //send slice
870
- let hd = {
870
+ let hd = { //用header傳key與value時, key不分大小寫, 故使用kebabCase
871
871
  'chunk-index': i,
872
872
  'chunk-total': chunkTotal,
873
873
  'package-id': packageId,
@@ -877,16 +877,66 @@ function WConverhpClient(opt) {
877
877
 
878
878
  }
879
879
 
880
- //send slice-merge
881
- let msg = {
882
- 'filename': fileTotalName,
883
- 'chunk-total': chunkTotal,
884
- 'package-id': packageId,
880
+ //send merge-slices-push
881
+ // console.log(`send merge-slices-push...`)
882
+ let resUpMgp = await send('upload-controller', { mode: 'merge-slices-push', fileHash: fileTotalHash, chunkTotal }, { dataType: 'json' })
883
+ // console.log('resUpMgp', resUpMgp)
884
+
885
+ //checkMerging
886
+ let checkMerging = () => {
887
+ let pm = genPm()
888
+
889
+ //queueId
890
+ let queueId = resUpMgp.queueId
891
+ // console.log('queueId', queueId)
892
+
893
+ let t = setInterval(() => {
894
+
895
+ //send merge-slices-get
896
+ // console.log(`send merge-slices-get...`)
897
+ send('upload-controller', { mode: 'merge-slices-get', fileHash: fileTotalHash, filename: fileTotalName, queueId }, { dataType: 'json' })
898
+ .then((res) => {
899
+ // console.log('res', res)
900
+ // res => {
901
+ // queueId,
902
+ // state,
903
+ // filename,
904
+ // path,
905
+ // msg: ...
906
+ // }
907
+
908
+ //check
909
+ if (res.state === 'done') {
910
+
911
+ //cbProgressMerge
912
+ cbProgressMerge({ prog: 100, m: 'download' })
913
+
914
+ //resUpMgr
915
+ let resUpMgr = {
916
+ ...res.msg,
917
+ }
918
+
919
+ pm.resolve(resUpMgr)
920
+ }
921
+
922
+ })
923
+ .catch((err) => {
924
+ console.log(err)
925
+ })
926
+ .finally(() => {
927
+ clearInterval(t)
928
+ })
929
+
930
+ }, 2000)
931
+
932
+ return pm
885
933
  }
886
- let resMg = await send('slice-merge', msg, { dataType: 'json', cbProgress: cbProgressMerge })
934
+
935
+ //checkMerging
936
+ let resUpMgr = await checkMerging()
887
937
 
888
938
  // console.log(`upload slice done`)
889
- return resMg
939
+ return resUpMgr
890
940
  }
891
941
 
892
942
  //execute
@@ -1046,7 +1096,7 @@ export default WConverhpClient
1046
1096
  <br class="clear">
1047
1097
 
1048
1098
  <footer>
1049
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Mon Apr 14 2025 15:34:24 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
1099
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Tue Apr 15 2025 14:44:02 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
1050
1100
  </footer>
1051
1101
 
1052
1102
  <script>prettyPrint();</script>
@@ -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="WConverhpServer.mjs.html">WConverhpServer.mjs</a>, <a href="WConverhpServer.mjs.html#line198">line 198</a>
83
+ <a href="WConverhpServer.mjs.html">WConverhpServer.mjs</a>, <a href="WConverhpServer.mjs.html#line197">line 197</a>
84
84
  </li></ul></dd>
85
85
 
86
86
 
@@ -789,7 +789,7 @@
789
789
  <br class="clear">
790
790
 
791
791
  <footer>
792
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Mon Apr 14 2025 15:34:24 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
792
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Tue Apr 15 2025 14:44:02 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
793
793
  </footer>
794
794
 
795
795
  <script>prettyPrint();</script>