You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix detection of added/removed files when a directory is moved or cloned (#1660)
Summary:
Pull Request resolved: #1660
Previously, when running on macOS without Watchman, when a directory was moved or cloned from another location (inside or outside a watch), the contents would *not* be detected by Metro at their new locations.
That's because the OS only sends us a "rename" event for the directory, and no events for any of its contents (unsurprisingly, because they haven't changed).
This stack introduces a new 'recrawl' event which watcher backends may fire when they are unable to determine whether the contents of an extant directory are new, and makes use of it in `NativeWatcher`.
This does not apply to Watchman, which has its own (similar) recrawl mechanism, and it doesn't apply on Linux or Windows, which currently use a recursive watcher that crawl all "new" directories and compares contents to a tracked file map.
Changelog:
```
- **[Fix]**: Detection of contents of directories moved or cloned into a watched location
```
Reviewed By: vzaidman
Differential Revision: D94362228
fbshipit-source-id: d652c60539338efa273e196166b75b2327d4b114
'reports directory as deleted when it is moved from a watched root to outside',
235
+
async()=>{
236
+
// Create a directory with a file in it inside the watch root, then move it out and check that both the directory and the file are reported as deleted.
237
+
constoutsideDir=awaitfsPromises.mkdtemp(
238
+
join(os.tmpdir(),'metro-file-map-unwatched-'),
239
+
);
240
+
241
+
awaiteventHelpers.allEvents(
242
+
()=>
243
+
fsPromises.rename(
244
+
join(watchRoot,'existing','to-move-out'),
245
+
join(outsideDir,'moved-out'),
246
+
),
247
+
watcherName==='Native'
248
+
? // NativeWatcher only emits an event for the directory, not contents
0 commit comments