braidfs 0.0.73 → 0.0.75
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/index.js +18 -3
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -659,6 +659,10 @@ async function proxy_url(url) {
|
|
|
659
659
|
subscribe: true,
|
|
660
660
|
retry: {
|
|
661
661
|
onRes: (res) => {
|
|
662
|
+
if (res.status !== 209) return console.log(
|
|
663
|
+
`FAILED TO CONNECT TO: ${url}\n` +
|
|
664
|
+
`GOT STATUS CODE: ${res.status}, expected 209.`)
|
|
665
|
+
|
|
662
666
|
console.log(`connected to ${url}`)
|
|
663
667
|
console.log(` editable = ${res.headers.get('editable')}`)
|
|
664
668
|
|
|
@@ -673,7 +677,7 @@ async function proxy_url(url) {
|
|
|
673
677
|
},
|
|
674
678
|
peer
|
|
675
679
|
}).then(x => {
|
|
676
|
-
x.subscribe(async update => {
|
|
680
|
+
if (x.status === 209) x.subscribe(async update => {
|
|
677
681
|
console.log(`got external update about ${url}`)
|
|
678
682
|
|
|
679
683
|
if (update.body) update.body = update.body_text
|
|
@@ -717,7 +721,7 @@ async function proxy_url(url) {
|
|
|
717
721
|
return
|
|
718
722
|
}
|
|
719
723
|
|
|
720
|
-
var
|
|
724
|
+
var in_parallel = create_parallel_promises(10)
|
|
721
725
|
braid_text.get(url, braid_text_get_options = {
|
|
722
726
|
parents: r.headers.get('version') && JSON.parse(`[${r.headers.get('version')}]`),
|
|
723
727
|
merge_type: 'dt',
|
|
@@ -725,7 +729,7 @@ async function proxy_url(url) {
|
|
|
725
729
|
subscribe: async (u) => {
|
|
726
730
|
if (u.version.length) {
|
|
727
731
|
self.signal_file_needs_writing()
|
|
728
|
-
|
|
732
|
+
in_parallel(() => send_out({...u, peer}))
|
|
729
733
|
}
|
|
730
734
|
},
|
|
731
735
|
})
|
|
@@ -920,3 +924,14 @@ async function file_exists(fullpath) {
|
|
|
920
924
|
function sha256(x) {
|
|
921
925
|
return require('crypto').createHash('sha256').update(x).digest('base64')
|
|
922
926
|
}
|
|
927
|
+
|
|
928
|
+
function create_parallel_promises(N) {
|
|
929
|
+
var q = []
|
|
930
|
+
var n = 0
|
|
931
|
+
return async f => {
|
|
932
|
+
q.push(f)
|
|
933
|
+
n++
|
|
934
|
+
while (q.length && n <= N) await q.shift()()
|
|
935
|
+
n--
|
|
936
|
+
}
|
|
937
|
+
}
|