-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] core: Use AtomWatcher on macOS #1677
Draft
sebn
wants to merge
6
commits into
master
Choose a base branch
from
atom-macos
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
69ebb2a
core/local/atom_watcher: Don't check platform in .producer()
sebn c7ef0af
test/support/helpers/scenarios: Don't run Windows scenarios on macOS
sebn 09292bc
test/scenarios: Generate atom/darwin captures
sebn 1c2fb61
test/unit/config: Fix test descriptions
sebn b9ff4fe
[FIXME] core/config: Use atom watcher by default on macOS
sebn 2b78bac
[FIXME] core/local/steps/producer: macOS LocalEventBuffer
sebn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,11 +12,12 @@ const watcher = require('@atom/watcher') | |
const Channel = require('./channel') | ||
const { INITIAL_SCAN_DONE } = require('./event') | ||
const defaultStater = require('../stater') | ||
const LocalEventBuffer = require('../chokidar/event_buffer') | ||
const logger = require('../../utils/logger') | ||
|
||
/*:: | ||
import type { Ignore } from '../../ignore' | ||
import type { AtomEvent } from './event' | ||
import type { AtomBatch, AtomEvent } from './event' | ||
|
||
export type Scanner = (string) => Promise<void> | ||
*/ | ||
|
@@ -61,12 +62,21 @@ class Producer { | |
syncPath: string | ||
ignore: Ignore | ||
watcher: * | ||
macOSBuffer: ?LocalEventBuffer<AtomBatch> | ||
*/ | ||
constructor(opts /*: { syncPath: string, ignore: Ignore } */) { | ||
this.channel = new Channel() | ||
this.syncPath = opts.syncPath | ||
this.ignore = opts.ignore | ||
this.watcher = null | ||
if (process.platform === 'darwin') { | ||
const timeoutInMs = process.env.NODE_ENV === 'test' ? 1000 : 10000 | ||
this.macOSBuffer = new LocalEventBuffer(timeoutInMs, batches => { | ||
for (const batch of batches) { | ||
this.process(batch) | ||
} | ||
}) | ||
} | ||
autoBind(this) | ||
} | ||
|
||
|
@@ -90,10 +100,15 @@ class Producer { | |
* the recursive option. | ||
*/ | ||
async start() { | ||
const macOSBuffer = this.macOSBuffer | ||
const onEventBatch = macOSBuffer | ||
? macOSBuffer.push.bind(macOSBuffer) | ||
: this.process | ||
|
||
this.watcher = await watcher.watchPath( | ||
this.syncPath, | ||
{ recursive: true }, | ||
this.process | ||
onEventBatch | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should we regenerate all captures with buffer? (I believe they were regenerated before reintroducing the buffer) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. also is the buffer necessary or not? |
||
) | ||
log.info(`Now watching ${this.syncPath}`) | ||
if (process.platform === 'linux') { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
[ | ||
[ | ||
{ | ||
"action": "created", | ||
"kind": "directory", | ||
"path": "dir" | ||
}, | ||
{ | ||
"action": "created", | ||
"kind": "file", | ||
"path": "file" | ||
} | ||
], | ||
[], | ||
[ | ||
{ | ||
"action": "deleted", | ||
"kind": "directory", | ||
"path": "dir" | ||
}, | ||
{ | ||
"action": "deleted", | ||
"kind": "file", | ||
"path": "file" | ||
} | ||
] | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
[ | ||
[ | ||
{ | ||
"action": "created", | ||
"kind": "file", | ||
"path": "file" | ||
} | ||
] | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
[ | ||
[ | ||
{ | ||
"action": "created", | ||
"kind": "directory", | ||
"path": "dir" | ||
} | ||
], | ||
[], | ||
[ | ||
{ | ||
"action": "deleted", | ||
"kind": "directory", | ||
"path": "dir" | ||
} | ||
] | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
[ | ||
[ | ||
{ | ||
"action": "created", | ||
"kind": "file", | ||
"path": "file" | ||
} | ||
], | ||
[ | ||
{ | ||
"action": "deleted", | ||
"kind": "file", | ||
"path": "file" | ||
} | ||
] | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
[ | ||
[ | ||
{ | ||
"action": "modified", | ||
"kind": "file", | ||
"path": "file" | ||
} | ||
] | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
[ | ||
[ | ||
{ | ||
"action": "renamed", | ||
"kind": "directory", | ||
"path": "dst/dir1", | ||
"oldPath": "src/dir1" | ||
}, | ||
{ | ||
"action": "created", | ||
"kind": "directory", | ||
"path": "dst/dir1/dir2" | ||
} | ||
], | ||
[] | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
[ | ||
[ | ||
{ | ||
"action": "created", | ||
"kind": "directory", | ||
"path": "foo" | ||
}, | ||
{ | ||
"action": "created", | ||
"kind": "directory", | ||
"path": "foo/bar" | ||
} | ||
], | ||
[], | ||
[ | ||
{ | ||
"action": "scan", | ||
"path": "foo/bar", | ||
"kind": "directory", | ||
"stats": { | ||
"dev": 16777226, | ||
"mode": 16877, | ||
"nlink": 2, | ||
"uid": 501, | ||
"gid": 20, | ||
"rdev": 0, | ||
"blksize": 4194304, | ||
"ino": 8600863105, | ||
"size": 64, | ||
"blocks": 0, | ||
"atimeMs": 1554478410553.5947, | ||
"mtimeMs": 1554478410533.3728, | ||
"ctimeMs": 1554478410533.3728, | ||
"birthtimeMs": 1554478410533.3728, | ||
"atime": "2019-04-05T15:33:30.554Z", | ||
"mtime": "2019-04-05T15:33:30.533Z", | ||
"ctime": "2019-04-05T15:33:30.533Z", | ||
"birthtime": "2019-04-05T15:33:30.533Z" | ||
} | ||
} | ||
], | ||
[] | ||
] |
18 changes: 18 additions & 0 deletions
18
test/scenarios/move_a_to_c_and_b_to_a_dir_dir_delay/atom/darwin.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
[ | ||
[ | ||
{ | ||
"action": "renamed", | ||
"kind": "directory", | ||
"path": "c", | ||
"oldPath": "a" | ||
} | ||
], | ||
[ | ||
{ | ||
"action": "renamed", | ||
"kind": "directory", | ||
"path": "a", | ||
"oldPath": "b" | ||
} | ||
] | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
[ | ||
[ | ||
{ | ||
"action": "renamed", | ||
"kind": "directory", | ||
"path": "dst/subdir", | ||
"oldPath": "src/subdir" | ||
} | ||
], | ||
[ | ||
{ | ||
"action": "deleted", | ||
"kind": "file", | ||
"path": "dst/subdir/file" | ||
} | ||
], | ||
[ | ||
{ | ||
"action": "deleted", | ||
"kind": "directory", | ||
"path": "dst/subdir" | ||
} | ||
] | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
[ | ||
[ | ||
{ | ||
"action": "renamed", | ||
"kind": "file", | ||
"path": "dst/file", | ||
"oldPath": "src/file" | ||
} | ||
], | ||
[ | ||
{ | ||
"action": "deleted", | ||
"kind": "file", | ||
"path": "dst/file" | ||
} | ||
] | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
[ | ||
[ | ||
{ | ||
"action": "renamed", | ||
"kind": "file", | ||
"path": "dst/file", | ||
"oldPath": "src/file" | ||
} | ||
], | ||
[ | ||
{ | ||
"action": "modified", | ||
"kind": "file", | ||
"path": "dst/file" | ||
} | ||
] | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
[ | ||
[ | ||
{ | ||
"action": "renamed", | ||
"kind": "directory", | ||
"path": "src/B", | ||
"oldPath": "src/A" | ||
} | ||
], | ||
[ | ||
{ | ||
"action": "renamed", | ||
"kind": "directory", | ||
"path": "src/C", | ||
"oldPath": "src/B" | ||
} | ||
], | ||
[ | ||
{ | ||
"action": "renamed", | ||
"kind": "directory", | ||
"path": "src/B", | ||
"oldPath": "src/C" | ||
} | ||
] | ||
] |
17 changes: 17 additions & 0 deletions
17
test/scenarios/move_dir_and_update_subfile/atom/darwin.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
[ | ||
[ | ||
{ | ||
"action": "renamed", | ||
"kind": "directory", | ||
"path": "dst", | ||
"oldPath": "src" | ||
} | ||
], | ||
[ | ||
{ | ||
"action": "modified", | ||
"kind": "file", | ||
"path": "dst/file" | ||
} | ||
] | ||
] |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
await?