braidfs 0.0.53 → 0.0.54
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 +38 -0
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -582,6 +582,44 @@ async function proxy_url(url) {
|
|
|
582
582
|
}).catch(e => (e?.name !== "AbortError") && crash(e))
|
|
583
583
|
}
|
|
584
584
|
|
|
585
|
+
// send them stuff we have but they don't
|
|
586
|
+
if (is_external_link) send_new_stuff()
|
|
587
|
+
async function send_new_stuff() {
|
|
588
|
+
if (!start_something()) return
|
|
589
|
+
try {
|
|
590
|
+
let a = new AbortController()
|
|
591
|
+
aborts.add(a)
|
|
592
|
+
var r = await braid_fetch(url, {
|
|
593
|
+
signal: a.signal,
|
|
594
|
+
method: "HEAD",
|
|
595
|
+
headers: {
|
|
596
|
+
Accept: 'text/plain',
|
|
597
|
+
...config.domains?.[(new URL(url)).hostname]?.auth_headers,
|
|
598
|
+
},
|
|
599
|
+
retry: true
|
|
600
|
+
})
|
|
601
|
+
aborts.delete(a)
|
|
602
|
+
|
|
603
|
+
if (r.headers.get('editable') === 'false') {
|
|
604
|
+
console.log('do not send updates for read-only file: ' + url)
|
|
605
|
+
return
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
var chain = Promise.resolve()
|
|
609
|
+
braid_text.get(url, braid_text_get_options = {
|
|
610
|
+
parents: r.headers.get('version') && JSON.parse(`[${r.headers.get('version')}]`),
|
|
611
|
+
merge_type: 'dt',
|
|
612
|
+
peer,
|
|
613
|
+
subscribe: async (u) => {
|
|
614
|
+
if (u.version.length) chain = chain.then(() => send_out({...u, peer}))
|
|
615
|
+
},
|
|
616
|
+
})
|
|
617
|
+
} catch (e) {
|
|
618
|
+
if (e?.name !== "AbortError") crash(e)
|
|
619
|
+
}
|
|
620
|
+
finish_something()
|
|
621
|
+
}
|
|
622
|
+
|
|
585
623
|
// for config and errors file, listen for web changes
|
|
586
624
|
if (!is_external_link) braid_text.get(url, braid_text_get_options = {
|
|
587
625
|
merge_type: 'dt',
|