Change information
Commit message:
gopls/internal/filewatcher: add poll-based watcher
Update poll watcher to support watching multiple root directories.
It also ensures that WatchDir performs a synchronous scan to establish a
baseline state if one doesn't exist, preventing missed events on startup.
At this point, the coarse-grained locking mechanism is not ideal but
sufficient since the only competing method is "WatchDir" and should
not be called frequently.
The test for file watcher no longer test the OS specific event order,
e.g. "new file" creation first or "old file" deletion first in a file
rename. The test focus on the existence of the wanted events regardless
of the order.
Windows uses mandatory file locking, when the poll watcher is scanning
the dir, other processes can not operate on the same file. The file
watcher's test have also changed to try with backoff to make sure the
operation can survive any transient error.
For golang/go#77814 golang/go#76291
Change-Id: Ieaac1cbc6ccc0ac1d0fc71dc9c48037a4dcf8a24
Files:
- M gopls/internal/cmd/mcp.go
- M gopls/internal/filewatcher/filewatcher.go
- M gopls/internal/filewatcher/filewatcher_test.go
- M gopls/internal/filewatcher/fsnotify_watcher.go
- A gopls/internal/filewatcher/poll_watcher.go
- M gopls/internal/settings/settings.go
Change size: L
Delta: 6 files changed, 678 insertions(+), 315 deletions(-)
Branch: refs/heads/master
Submit Requirements:
Code-Review: +2 by Alan Donovan
TryBots-Pass: LUCI-TryBot-Result+1 by Go LUCI