braidfs 0.0.107 → 0.0.109

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 +16 -4
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -291,12 +291,16 @@ async function watch_files() {
291
291
  await w?.close()
292
292
 
293
293
  console.log('watch files..')
294
- watch_files.watcher = require('chokidar').watch(sync_base).
295
- on('add', x => chokidar_handler(x, 'add')).
294
+ watch_files.watcher = require('chokidar').watch(sync_base, {
295
+ useFsEvents: true,
296
+ usePolling: false,
297
+ }). on('add', x => chokidar_handler(x, 'add')).
296
298
  on('change', x => chokidar_handler(x, 'change')).
297
299
  on('unlink', x => chokidar_handler(x, 'unlink'))
298
300
 
299
301
  async function chokidar_handler(fullpath, event) {
302
+ console.log(`file event "${event}": ${fullpath}`)
303
+
300
304
  // Make sure the path is within sync_base..
301
305
  if (!fullpath.startsWith(sync_base))
302
306
  return on_watcher_miss(`path ${fullpath} outside ${sync_base}`)
@@ -309,8 +313,6 @@ async function watch_files() {
309
313
  if (event != 'unlink' && (await require('fs').promises.stat(fullpath)).isDirectory())
310
314
  return on_watcher_miss(`expected file, got: ${fullpath}`)
311
315
 
312
- console.log(`file event: ${path}, event: ${event}`)
313
-
314
316
  var sync = await sync_url.cache[normalize_url(path)]
315
317
 
316
318
  if (sync && event != 'add') sync.signal_file_needs_reading()
@@ -330,6 +332,16 @@ async function scan_files() {
330
332
  'en-US', {minute: '2-digit', second: '2-digit', hour: '2-digit'}
331
333
  )
332
334
  console.log(`scan files.. `, timestamp)
335
+
336
+ // this can be removed in the future;
337
+ // some debug information about chokidar:
338
+ var internal = 'unknown'
339
+ for (var k in watch_files?.watcher ?? {}) {
340
+ if (k.startsWith('_fsEvents')) internal = "_fsEvents"
341
+ if (k.startsWith('_nodeFs')) internal = "_nodeFs"
342
+ }
343
+ console.log(`chokidar info: FSEvents=${watch_files?.watcher?.options?.useFsEvents}, polling=${watch_files?.watcher?.options?.usePolling}, internal=${internal}`)
344
+
333
345
  if (await f(sync_base))
334
346
  on_watcher_miss(`scanner picked up a change that the watcher should have gotten`, false)
335
347
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "braidfs",
3
- "version": "0.0.107",
3
+ "version": "0.0.109",
4
4
  "description": "braid technology synchronizing files and webpages",
5
5
  "author": "Braid Working Group",
6
6
  "repository": "braid-org/braidfs",