diff options
author | Lucas Holmquist <lholmqui@redhat.com> | 2019-10-14 11:57:24 -0400 |
---|---|---|
committer | Anna Henningsen <anna@addaleax.net> | 2019-11-19 16:05:21 +0100 |
commit | 535e9571f5252ea9ce6f5db12f700f73af6df055 (patch) | |
tree | e0afe09f53f7cfc5a60e4d718c71a673fe023714 /lib/internal | |
parent | 4f434187ff06cc8ac9e2022e65d6f6bf2fb8a19e (diff) | |
download | android-node-v8-535e9571f5252ea9ce6f5db12f700f73af6df055.tar.gz android-node-v8-535e9571f5252ea9ce6f5db12f700f73af6df055.tar.bz2 android-node-v8-535e9571f5252ea9ce6f5db12f700f73af6df055.zip |
fs: make FSStatWatcher.start private
An instance of FSStatWatcher is returned when a user calls fs.watchFile,
which will call the start method. A user can't create an instance
of a FSStatWatcher directly. If the start method is called by a user
it is a noop since the watcher has already started.
This "Class" is currently undocumented.
PR-URL: https://github.com/nodejs/node/pull/29971
Reviewed-By: David Carlier <devnexen@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Michaƫl Zasso <targos@protonmail.com>
Diffstat (limited to 'lib/internal')
-rw-r--r-- | lib/internal/fs/watchers.js | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/lib/internal/fs/watchers.js b/lib/internal/fs/watchers.js index c974f40aae..0685bcef4d 100644 --- a/lib/internal/fs/watchers.js +++ b/lib/internal/fs/watchers.js @@ -26,6 +26,7 @@ const kOldStatus = Symbol('kOldStatus'); const kUseBigint = Symbol('kUseBigint'); const kFSWatchStart = Symbol('kFSWatchStart'); +const kFSStatWatcherStart = Symbol('kFSStatWatcherStart'); function emitStop(self) { self.emit('stop'); @@ -54,13 +55,15 @@ function onchange(newStatus, stats) { getStatsFromBinding(stats, kFsStatsFieldsNumber)); } -// FIXME(joyeecheung): this method is not documented. // At the moment if filename is undefined, we -// 1. Throw an Error if it's the first time .start() is called -// 2. Return silently if .start() has already been called +// 1. Throw an Error if it's the first +// time Symbol('kFSStatWatcherStart') is called +// 2. Return silently if Symbol('kFSStatWatcherStart') has already been called // on a valid filename and the wrap has been initialized // This method is a noop if the watcher has already been started. -StatWatcher.prototype.start = function(filename, persistent, interval) { +StatWatcher.prototype[kFSStatWatcherStart] = function(filename, + persistent, + interval) { if (this._handle !== null) return; @@ -88,6 +91,12 @@ StatWatcher.prototype.start = function(filename, persistent, interval) { } }; +// To maximize backward-compatiblity for the end user, +// a no-op stub method has been added instead of +// totally removing StatWatcher.prototpye.start. +// This should not be documented. +StatWatcher.prototype.start = () => {}; + // FIXME(joyeecheung): this method is not documented while there is // another documented fs.unwatchFile(). The counterpart in // FSWatcher is .close() @@ -209,5 +218,6 @@ Object.defineProperty(FSEvent.prototype, 'owner', { module.exports = { FSWatcher, StatWatcher, - kFSWatchStart + kFSWatchStart, + kFSStatWatcherStart }; |