Inist-CNRS / node-inotifywait

Yet another nodejs fs.watch/inotify implementation. Good for large directory structure with lot of files.
MIT License
23 stars 8 forks source link

Breaks when files contain newlines #13

Open haynesgt opened 4 years ago

haynesgt commented 4 years ago

e.g. if you touch $'a\nb' in a watched directory you get

Error: SyntaxError: Unexpected end of JSON input -> { "type": "OPEN", "file": "/tmp/thing/a
    at /tmp/in/node_modules/inotifywait/lib/inotifywait.js:85:32
    at /tmp/in/node_modules/lazy/lazy.js:99:35
    at Lazy.<anonymous> (/tmp/in/node_modules/lazy/lazy.js:74:37)
    at Lazy.emit (events.js:315:20)
    at Lazy.EventEmitter.emit (domain.js:506:15)
    at Lazy.<anonymous> (/tmp/in/node_modules/lazy/lazy.js:74:22)
    at Lazy.emit (events.js:315:20)
    at Lazy.EventEmitter.emit (domain.js:506:15)
    at yieldTo (/tmp/in/node_modules/lazy/lazy.js:181:18)

You need to use the csv output option from inotifywait and parse that.

nhjm449 commented 2 years ago

Also when filenames contain " or \, since the encoding method provides no safety.