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.
- package/README.md +1 -1
- package/dist/w-converhp-client.umd.js +2 -2
- package/dist/w-converhp-client.umd.js.map +1 -1
- package/dist/w-converhp-server.umd.js +2 -2
- package/dist/w-converhp-server.umd.js.map +1 -1
- package/docs/WConverhpClient.html +1 -1
- package/docs/WConverhpClient.mjs.html +84 -34
- package/docs/WConverhpServer.html +2 -2
- package/docs/WConverhpServer.mjs.html +131 -304
- package/docs/index.html +1 -1
- package/package.json +1 -1
- package/scla.mjs +3 -0
- package/sclb.mjs +3 -0
- package/sclc.mjs +4 -1
- package/scld.mjs +3 -0
- package/script.txt +4 -4
- package/src/WConverhpClient.mjs +83 -33
- package/src/WConverhpServer.mjs +130 -303
- package/src/checkSlicesHash.mjs +68 -0
- package/src/checkSlicesHash.wk.umd.js +1 -0
- package/src/checkTotalHash.mjs +107 -0
- package/src/checkTotalHash.wk.umd.js +1 -0
- package/src/managerMergeSlices.mjs +82 -0
- package/src/mergeSlices.mjs +31 -0
- package/src/mergeSlices.wk.umd.js +1 -0
- package/test/downloadLargeFile.test.mjs +3 -0
- package/test/executeWithFile.test.mjs +3 -0
- package/test/executeWithU8a.test.mjs +3 -0
- package/test/uploadLargeFile.test.mjs +9 -5
- package/toolg/gDistRollup.mjs +48 -4
- package/src/calcFileHash.mjs +0 -10
- package/src/calcFileHash.wk.umd.js +0 -1
- package/src/mergeFiles.mjs +0 -27
- package/src/mergeFiles.wk.umd.js +0 -1
|
@@ -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
|
|
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-
|
|
215
|
-
urlUse = `${url}
|
|
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
|
|
732
|
+
//send check-total-hash
|
|
733
733
|
// console.log(`send check-total-hash...`)
|
|
734
|
-
let
|
|
735
|
-
// console.log('
|
|
736
|
-
//
|
|
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 (
|
|
752
|
+
if (resUpCkt.bAllHash) {
|
|
753
753
|
// console.log('已有上傳大檔')
|
|
754
754
|
let resMg = {
|
|
755
755
|
filename: fileTotalName,
|
|
756
|
-
path:
|
|
756
|
+
path: resUpCkt.path,
|
|
757
757
|
}
|
|
758
758
|
return resMg
|
|
759
759
|
}
|
|
760
760
|
|
|
761
761
|
//針對伺服器上已有切片檔案計算hash與比對
|
|
762
|
-
if (
|
|
763
|
-
// console.log('receive 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(
|
|
768
|
-
// let nr = Math.floor(n /
|
|
769
|
-
for (let k = 0; k <
|
|
767
|
+
// let n = Math.max(resUpCkt.slks.length, 1)
|
|
768
|
+
// let nr = Math.floor(n / 100)
|
|
769
|
+
for (let k = 0; k < resUpCkt.slks.length; k++) {
|
|
770
770
|
// if (k % nr === 0) {
|
|
771
|
-
// console.log(`calc hash for slices`, round(k /
|
|
771
|
+
// console.log(`calc hash for slices`, round(k / resUpCkt.slks.length * 100, 1), '%')
|
|
772
772
|
// }
|
|
773
773
|
|
|
774
774
|
//i
|
|
775
|
-
let i =
|
|
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
|
|
799
|
+
//send check-slices-hash
|
|
800
800
|
// console.log(`send check-slices-hash...`)
|
|
801
|
-
let
|
|
802
|
-
// console.log('
|
|
803
|
-
//
|
|
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
|
-
|
|
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 < chunkTotal; i++) {
|
|
852
852
|
|
|
853
853
|
//check
|
|
854
|
-
if (
|
|
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
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
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
|
-
|
|
934
|
+
|
|
935
|
+
//checkMerging
|
|
936
|
+
let resUpMgr = await checkMerging()
|
|
887
937
|
|
|
888
938
|
// console.log(`upload slice done`)
|
|
889
|
-
return
|
|
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
|
|
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#
|
|
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
|
|
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>
|