diff --git a/CHANGELOG.md b/CHANGELOG.md index 59b4db46c..aa8f85ff3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ IMPROVEMENTS: - commands/plugin: Better error output is shown when plugin installation fails. - commands/reload: show post up messsage [GH-4168] + - commands/rsync-auto: Add `--poll` flag. [GH-4392] - communicators/winrm: Show stdout/stderr if command fails. [GH-4094] - guests/nixos: Added better NFS support. [GH-3983] - providers/hyperv: Accept VHD disk format. [GH-4208] diff --git a/plugins/synced_folders/rsync/command/rsync_auto.rb b/plugins/synced_folders/rsync/command/rsync_auto.rb index 573e18430..82b573a7f 100644 --- a/plugins/synced_folders/rsync/command/rsync_auto.rb +++ b/plugins/synced_folders/rsync/command/rsync_auto.rb @@ -28,9 +28,16 @@ module VagrantPlugins def execute @logger = Log4r::Logger.new("vagrant::commands::rsync-auto") + options = {} opts = OptionParser.new do |o| o.banner = "Usage: vagrant rsync-auto [vm-name]" o.separator "" + o.separator "Options:" + o.separator "" + + o.on("--[no-]poll", "Force polling filesystem (slow)") do |poll| + options[:poll] = poll + end end # Parse the options and return if we don't have any target. @@ -106,7 +113,8 @@ module VagrantPlugins end @logger.info("Listening via: #{Listen::Adapter.select.inspect}") callback = method(:callback).to_proc.curry[paths] - listener = Listen.to(*paths.keys, ignore: ignores, &callback) + listopts = { ignore: ignores, force_polling: !!opts[:poll] } + listener = Listen.to(*paths.keys, listopts, &callback) # Create the callback that lets us know when we've been interrupted queue = Queue.new diff --git a/website/docs/source/v2/cli/rsync-auto.html.md b/website/docs/source/v2/cli/rsync-auto.html.md index 679b8fad8..eae26fb7b 100644 --- a/website/docs/source/v2/cli/rsync-auto.html.md +++ b/website/docs/source/v2/cli/rsync-auto.html.md @@ -15,6 +15,13 @@ not exit until an interrupt is received. The change detection is optimized to use platform-specific APIs to listen for filesystem changes, and does not simply poll the directory. +## Options + +* `--[no-]poll` - Force Vagrant to watch for changes using filesystem + polling instead of filesystem events. This is required for some filesystems + that don't support events. Warning: enabling this will make `rsync-auto` + _much_ slower. By default, polling is disabled. + ## Machine State Changes The `rsync-auto` command does not currently handle machine state changes