braidfs 0.0.76 → 0.0.77

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.
Files changed (2) hide show
  1. package/index.js +14 -5
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -263,6 +263,10 @@ async function trash_file(fullpath, path) {
263
263
  await require('fs').promises.rename(fullpath, dest)
264
264
 
265
265
  // and log an error
266
+ await log_error(`error: unsynced file ${fullpath}; moved to ${dest}`)
267
+ }
268
+
269
+ async function log_error(text) {
266
270
  var x = await braid_text.get('.braidfs/errors', {}),
267
271
  len = [...x.body].length
268
272
  await braid_text.put('.braidfs/errors', {
@@ -270,7 +274,7 @@ async function trash_file(fullpath, path) {
270
274
  patches: [{
271
275
  unit: 'text',
272
276
  range: `[${len}:${len}]`,
273
- content: `error: unsynced file ${fullpath}; moved to ${dest}\n`
277
+ content: `${text}\n`
274
278
  }]
275
279
  })
276
280
  }
@@ -676,9 +680,12 @@ async function proxy_url(url) {
676
680
  subscribe: true,
677
681
  retry: {
678
682
  onRes: (res) => {
679
- if (res.status !== 209) return console.log(
680
- `FAILED TO CONNECT TO: ${url}\n` +
681
- `GOT STATUS CODE: ${res.status}, expected 209.`)
683
+ if (res.status !== 209) {
684
+ log_error(`Can't sync ${url} -- got bad response ${res.status} from server (expected 209)`)
685
+ return console.log(
686
+ `FAILED TO CONNECT TO: ${url}\n` +
687
+ `GOT STATUS CODE: ${res.status}, expected 209.`)
688
+ }
682
689
 
683
690
  console.log(`connected to ${url}`)
684
691
  console.log(` editable = ${res.headers.get('editable')}`)
@@ -738,8 +745,10 @@ async function proxy_url(url) {
738
745
  return
739
746
  }
740
747
 
741
- if (r.headers.get('version') == null)
748
+ if (r.headers.get('version') == null) {
749
+ log_error(`Can't sync ${url} -- got no version from server`)
742
750
  return console.log(`GOT NO VERSION FROM: ${url}`)
751
+ }
743
752
  var parents = JSON.parse(`[${r.headers.get('version')}]`)
744
753
 
745
754
  var bytes = (await braid_text.get_resource(url)).doc.toBytes()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "braidfs",
3
- "version": "0.0.76",
3
+ "version": "0.0.77",
4
4
  "description": "braid technology synchronizing files and webpages",
5
5
  "author": "Braid Working Group",
6
6
  "repository": "braid-org/braidfs",