mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
Enable 'poll' option for @atom/notify-based fs watching
This commit is contained in:
6
package-lock.json
generated
6
package-lock.json
generated
@@ -456,9 +456,9 @@
|
||||
}
|
||||
},
|
||||
"@atom/notify": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/@atom/notify/-/notify-1.1.0.tgz",
|
||||
"integrity": "sha512-oSIz5/tMTQeJ9V93wensUdVaVEtU+HHykswME51gYI4VQw/WJ0ofT+0h/b5velHte83MrFRfB65pE+DS82PjUQ=="
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/@atom/notify/-/notify-1.2.0.tgz",
|
||||
"integrity": "sha512-M13bjK+w7JM/p/qnnOb6Z/vPjBZKRGkantO0zqtuZAHXmY6LcWdoO899ev5vXcqYFbGrGuMbrwTHORqgjFpuJw=="
|
||||
},
|
||||
"@atom/nsfw": {
|
||||
"version": "1.0.22",
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
"license": "MIT",
|
||||
"electronVersion": "2.0.18",
|
||||
"dependencies": {
|
||||
"@atom/notify": "1.1.0",
|
||||
"@atom/notify": "1.2.0",
|
||||
"@atom/nsfw": "1.0.22",
|
||||
"@atom/source-map-support": "^0.3.4",
|
||||
"@atom/watcher": "1.3.1",
|
||||
|
||||
@@ -329,17 +329,17 @@ const configSchema = {
|
||||
default: 40
|
||||
},
|
||||
fileSystemWatcher: {
|
||||
description: 'Choose the underlying implementation used to watch for filesystem changes. Emulating changes will miss any events caused by applications other than Atom, but may help prevent crashes or freezes.<br>This setting will require a relaunch of Atom to take effect.',
|
||||
description: 'Choose the underlying implementation used to watch for filesystem changes. Emulating changes will miss any events caused by applications other than Atom, but may help prevent crashes or freezes. Polling may be useful for network drives, but will be more costly in terms of CPU overhead.<br>This setting will require a relaunch of Atom to take effect.',
|
||||
type: 'string',
|
||||
default: 'experimental',
|
||||
enum: [
|
||||
{
|
||||
value: 'native',
|
||||
description: 'Native operating system APIs'
|
||||
description: 'Native operating system APIs (@atom/nsfw)'
|
||||
},
|
||||
{
|
||||
value: 'experimental',
|
||||
description: 'Experimental filesystem watching library'
|
||||
description: 'Experimental (@atom/notify)'
|
||||
},
|
||||
{
|
||||
value: 'poll',
|
||||
@@ -351,6 +351,11 @@ const configSchema = {
|
||||
}
|
||||
]
|
||||
},
|
||||
fileSystemWatcherPollInterval: {
|
||||
description: "If the 'Polling' option is selected for the file system watcher, this will be the interval between polls.",
|
||||
type: 'number',
|
||||
default: 1000
|
||||
},
|
||||
useTreeSitterParsers: {
|
||||
type: 'boolean',
|
||||
default: true,
|
||||
|
||||
@@ -545,14 +545,18 @@ class PathWatcherManager {
|
||||
// Private: Access the currently active manager instance, creating one if necessary.
|
||||
static active () {
|
||||
if (!this.activeManager) {
|
||||
this.activeManager = new PathWatcherManager(atom.config.get('core.fileSystemWatcher'))
|
||||
this.activeManager = new PathWatcherManager(
|
||||
atom.config.get('core.fileSystemWatcher'),
|
||||
atom.config.get('core.fileSystemWatcherPollInterval')
|
||||
)
|
||||
}
|
||||
return this.activeManager
|
||||
}
|
||||
|
||||
// Private: Initialize global {PathWatcher} state.
|
||||
constructor (setting) {
|
||||
constructor (setting, pollInterval) {
|
||||
this.setting = setting
|
||||
this.pollInterval = pollInterval
|
||||
this.live = new Map()
|
||||
|
||||
const initLocal = NativeConstructor => {
|
||||
@@ -586,16 +590,17 @@ class PathWatcherManager {
|
||||
async watchPath (rootPath, options, eventCallback) {
|
||||
if (this.useExperimentalWatcher()) {
|
||||
if (!this.notifyWatcher) {
|
||||
this.notifyWatcher = new NotifyWatcher({onError: (error) => {
|
||||
throw new Error(`Error watching file system: ${error}`)
|
||||
}})
|
||||
const options = {
|
||||
onError: (error) => {
|
||||
throw new Error(`Error watching file system: ${error}`)
|
||||
}
|
||||
}
|
||||
if (this.setting === 'poll') {
|
||||
options.pollInterval = this.pollInterval
|
||||
}
|
||||
this.notifyWatcher = new NotifyWatcher(options)
|
||||
}
|
||||
|
||||
// TODO: Figure out how to handle the poll setting
|
||||
// if (this.setting === 'poll') {
|
||||
// options.poll = true
|
||||
// }
|
||||
|
||||
const watch = await this.notifyWatcher.watchPath(rootPath, event => {
|
||||
if (event.action === 'error') {
|
||||
watch.emitter.emit('error', event.description)
|
||||
|
||||
Reference in New Issue
Block a user