From f08396429e556e799f345c054ea1862be733bc71 Mon Sep 17 00:00:00 2001 From: Benny Born Date: Fri, 2 Jul 2021 10:17:52 +0200 Subject: [PATCH 1/5] make sure path is not undefined (fix #20871) --- src/path-watcher.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/path-watcher.js b/src/path-watcher.js index 2fed722c5cb..707d1127002 100644 --- a/src/path-watcher.js +++ b/src/path-watcher.js @@ -294,8 +294,8 @@ class NSFWNativeWatcher extends NativeWatcher { if (event.file) { payload.path = path.join(event.directory, event.file); } else { - payload.oldPath = path.join(event.directory, event.oldFile); - payload.path = path.join(event.directory, event.newFile); + payload.oldPath = path.join(event.directory, event.oldFile??''); + payload.path = path.join(event.directory, event.newFile??''); } return payload; From 54de31c005a6aac4220ac6cd1f8e0847e21ac4f9 Mon Sep 17 00:00:00 2001 From: Benny Born Date: Fri, 2 Jul 2021 18:23:14 +0200 Subject: [PATCH 2/5] Apply suggestions from code review Co-authored-by: steven nguyen --- src/path-watcher.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/path-watcher.js b/src/path-watcher.js index 707d1127002..a8d68ba3c9c 100644 --- a/src/path-watcher.js +++ b/src/path-watcher.js @@ -294,8 +294,8 @@ class NSFWNativeWatcher extends NativeWatcher { if (event.file) { payload.path = path.join(event.directory, event.file); } else { - payload.oldPath = path.join(event.directory, event.oldFile??''); - payload.path = path.join(event.directory, event.newFile??''); + payload.oldPath = path.join(event.directory, event.oldFile == undefined ? '' : event.oldFile); + payload.path = path.join(event.directory, event.newFile == undefined ? '' : event.newFile); } return payload; From ca6a451e5802c12ff8d2bd35174aedc7b8e94301 Mon Sep 17 00:00:00 2001 From: Benny Born Date: Fri, 2 Jul 2021 18:37:58 +0200 Subject: [PATCH 3/5] Update path-watcher.js apply changes suggested by linter --- src/path-watcher.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/path-watcher.js b/src/path-watcher.js index a8d68ba3c9c..0591faef508 100644 --- a/src/path-watcher.js +++ b/src/path-watcher.js @@ -294,8 +294,14 @@ class NSFWNativeWatcher extends NativeWatcher { if (event.file) { payload.path = path.join(event.directory, event.file); } else { - payload.oldPath = path.join(event.directory, event.oldFile == undefined ? '' : event.oldFile); - payload.path = path.join(event.directory, event.newFile == undefined ? '' : event.newFile); + payload.oldPath = path.join( + event.directory, + (typeof event.oldFile === 'undefined') ? '' : event.oldFile + ); + payload.path = path.join( + event.directory, + (typeof event.newFile === 'undefined') ? '' : event.newFile + ); } return payload; From cf6539b0963c741830e39489ac7791b22c1ab340 Mon Sep 17 00:00:00 2001 From: Benny Born Date: Fri, 2 Jul 2021 18:41:50 +0200 Subject: [PATCH 4/5] Apply changes suggested by linter --- src/path-watcher.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/path-watcher.js b/src/path-watcher.js index 0591faef508..f83d3a3194b 100644 --- a/src/path-watcher.js +++ b/src/path-watcher.js @@ -296,11 +296,11 @@ class NSFWNativeWatcher extends NativeWatcher { } else { payload.oldPath = path.join( event.directory, - (typeof event.oldFile === 'undefined') ? '' : event.oldFile + typeof event.oldFile === 'undefined' ? '' : event.oldFile ); payload.path = path.join( event.directory, - (typeof event.newFile === 'undefined') ? '' : event.newFile + typeof event.newFile === 'undefined' ? '' : event.newFile ); } From d790c4bbc28fdbc3dece028ec6c85b4e64d25fd3 Mon Sep 17 00:00:00 2001 From: Benny Born Date: Fri, 2 Jul 2021 18:46:43 +0200 Subject: [PATCH 5/5] Apply changes suggested by linter --- src/path-watcher.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/path-watcher.js b/src/path-watcher.js index f83d3a3194b..11064eaf28a 100644 --- a/src/path-watcher.js +++ b/src/path-watcher.js @@ -299,7 +299,7 @@ class NSFWNativeWatcher extends NativeWatcher { typeof event.oldFile === 'undefined' ? '' : event.oldFile ); payload.path = path.join( - event.directory, + event.directory, typeof event.newFile === 'undefined' ? '' : event.newFile ); }