From 999c25a6059f7876f38eb1140538e933e6145383 Mon Sep 17 00:00:00 2001 From: Alexander Kozinko Date: Tue, 3 Aug 2021 19:03:11 +0300 Subject: [PATCH] Support file names that start with uncode characters on linux Signed-off-by: Alexander Kozinko --- js/spec/index-spec.js | 33 +++++++++++++++++++++++++++++++++ src/linux/InotifyEventLoop.cpp | 4 ---- 2 files changed, 33 insertions(+), 4 deletions(-) diff --git a/js/spec/index-spec.js b/js/spec/index-spec.js index 26c3c24f..e30720ef 100644 --- a/js/spec/index-spec.js +++ b/js/spec/index-spec.js @@ -704,6 +704,39 @@ describe('Node Sentinel File Watcher', function() { watch = null; } }); + + it('supports watching unicode directories and uncode files', async function() { + const file = 'は.starts_with_unicode'; + let eventFound = false; + + function findEvent(element) { + if ( + element.action === nsfw.actions.CREATED && + element.directory === watchPath && + element.file === file + ) { + eventFound = true; + } + } + + let watch = await nsfw( + workDir, + events => events.forEach(findEvent), + { debounceMS: DEBOUNCE } + ); + + try { + await watch.start(); + await sleep(TIMEOUT_PER_STEP); + await fse.writeFile(path.join(watchPath, file), 'Unicode though.'); + await sleep(TIMEOUT_PER_STEP); + + assert.ok(eventFound); + } finally { + await watch.stop(); + watch = null; + } + }); }); describe('Garbage collection', function() { diff --git a/src/linux/InotifyEventLoop.cpp b/src/linux/InotifyEventLoop.cpp index ecbe3ed0..69201d3b 100644 --- a/src/linux/InotifyEventLoop.cpp +++ b/src/linux/InotifyEventLoop.cpp @@ -108,10 +108,6 @@ void InotifyEventLoop::work() { isDirectoryRemoval = event->mask & (uint32_t)(IN_IGNORED | IN_DELETE_SELF); isDirectoryEvent = event->mask & (uint32_t)(IN_ISDIR); - if (!isDirectoryRemoval && *event->name <= 31) { - continue; - } - if (event->mask & (uint32_t)(IN_ATTRIB | IN_MODIFY)) { modify(); } else if (event->mask & (uint32_t)IN_CREATE) {