braidfs 0.0.77 → 0.0.79
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 +8 -9
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -61,24 +61,24 @@ if (argv.length === 1 && argv[0].match(/^(run|serve)$/)) {
|
|
|
61
61
|
} else if (argv.length && argv.length % 2 == 0 && argv.every((x, i) => i % 2 != 0 || x.match(/^(sync|unsync)$/))) {
|
|
62
62
|
return (async () => {
|
|
63
63
|
for (let i = 0; i < argv.length; i += 2) {
|
|
64
|
-
var
|
|
64
|
+
var sync = argv[i] === 'sync',
|
|
65
65
|
url = argv[i + 1]
|
|
66
66
|
if (!url.match(/^https?:\/\//)) {
|
|
67
67
|
if (url.startsWith('/')) url = require('path').relative(proxy_base, url)
|
|
68
68
|
url = `https://${url}`
|
|
69
69
|
}
|
|
70
|
-
console.log(`${
|
|
70
|
+
console.log(`${sync ? '' : 'un'}subscribing ${sync ? 'to' : 'from'} ${url}`)
|
|
71
71
|
try {
|
|
72
72
|
var res = await braid_fetch(`http://localhost:${config.port}/.braidfs/config`, {
|
|
73
73
|
method: 'PUT',
|
|
74
74
|
patches: [{
|
|
75
75
|
unit: 'json',
|
|
76
76
|
range: `sync[${JSON.stringify(url)}]`,
|
|
77
|
-
content:
|
|
77
|
+
content: sync ? 'true' : ''
|
|
78
78
|
}]
|
|
79
79
|
})
|
|
80
80
|
if (res.ok) {
|
|
81
|
-
console.log(
|
|
81
|
+
console.log(`Now ${sync ? '' : 'un'}subscribed ${sync ? 'to' : 'from'} ${url} in ~/http/.braidfs/config`)
|
|
82
82
|
} else {
|
|
83
83
|
console.log(`failed to ${operation} ${url}`)
|
|
84
84
|
console.log(`server responded with ${res.status}: ${await res.text()}`)
|
|
@@ -91,7 +91,6 @@ You can run it with:
|
|
|
91
91
|
return
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
|
-
console.log('All operations completed successfully.')
|
|
95
94
|
})()
|
|
96
95
|
} else {
|
|
97
96
|
return console.log(`Usage:
|
|
@@ -490,7 +489,7 @@ async function proxy_url(url) {
|
|
|
490
489
|
signal: a.signal,
|
|
491
490
|
headers: {
|
|
492
491
|
"Merge-Type": "dt",
|
|
493
|
-
"Content-Type": '
|
|
492
|
+
"Content-Type": '*/*',
|
|
494
493
|
...(x => x && {Cookie: x})(config.cookies?.[new URL(url).hostname])
|
|
495
494
|
},
|
|
496
495
|
method: "PUT",
|
|
@@ -674,7 +673,7 @@ async function proxy_url(url) {
|
|
|
674
673
|
signal: a.signal,
|
|
675
674
|
headers: {
|
|
676
675
|
"Merge-Type": "dt",
|
|
677
|
-
Accept: '
|
|
676
|
+
Accept: '*/*',
|
|
678
677
|
...(x => x && {Cookie: x})(config.cookies?.[new URL(url).hostname]),
|
|
679
678
|
},
|
|
680
679
|
subscribe: true,
|
|
@@ -733,7 +732,7 @@ async function proxy_url(url) {
|
|
|
733
732
|
signal: a.signal,
|
|
734
733
|
method: "HEAD",
|
|
735
734
|
headers: {
|
|
736
|
-
Accept: '
|
|
735
|
+
Accept: '*/*',
|
|
737
736
|
...(x => x && {Cookie: x})(config.cookies?.[new URL(url).hostname]),
|
|
738
737
|
},
|
|
739
738
|
retry: true
|
|
@@ -781,7 +780,7 @@ async function proxy_url(url) {
|
|
|
781
780
|
method: "HEAD",
|
|
782
781
|
parents,
|
|
783
782
|
headers: {
|
|
784
|
-
Accept: '
|
|
783
|
+
Accept: '*/*',
|
|
785
784
|
...(x => x && {Cookie: x})(config.cookies?.[new URL(url).hostname]),
|
|
786
785
|
},
|
|
787
786
|
retry: true
|