vagrant-syncer 1.1.8 → 1.1.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 87f0de4b26b2a4925479368125aeebb54acd4746
4
- data.tar.gz: b65baa6db0cdbf65635145d1e0df18ba262c671a
3
+ metadata.gz: 1f63a13b751a40347aeaa89ae2b248ddc639a240
4
+ data.tar.gz: e6cd70fd78bdf3eab3bbaf4e90b22c09714d82f1
5
5
  SHA512:
6
- metadata.gz: ed08fa4bc963c82f076a03df602ca51a719633379c120669b6c704c0b56b997115fb8bbd0eeab216f95efae085d8f67a0c8a4e8144a2e0aa9553f174fc478ec9
7
- data.tar.gz: cf46a519718b0beaad24c91b5d786b83034712990afa9178ac23d08429cdb01a598be214049a1ede52cb246b2f7065d11862b09bc0d653601ed8b0c040abea66
6
+ metadata.gz: a4a245961c35ebd74bff1b309835b23041061bddf57d3e2ceb866b440a71c9d0c1ee9758d74f8913f354f0a8049d26cac915f73b3dcf4b6d1572f73ce86eb01b
7
+ data.tar.gz: 3247be65105b04e43f48c3112bd392d99fbf9d49c464da73f3f985654c61ea650eafb60d0e6c74f84a6f7a4a0abd8034f5ff34e9449602268db606f9576006d9
@@ -4,7 +4,7 @@
4
4
  Vagrant.configure(2) do |config|
5
5
  config.vm.box = 'ubuntu/trusty64'
6
6
 
7
- # Disable checking updates for faster start up.
7
+ # Disable checking updates for faster startup.
8
8
  config.vm.box_check_update = false
9
9
  config.vbguest.auto_update = false if Vagrant.has_plugin?("vagrant-vbguest")
10
10
 
@@ -54,6 +54,14 @@ Vagrant.configure(2) do |config|
54
54
  # Default: true
55
55
  config.syncer.run_on_startup = true
56
56
 
57
+ # Whether or not to rsync on machine up before provisioners are ran.
58
+ #
59
+ # Please do note that this does not affect to the behaviour of rsync-auto,
60
+ # as it does a full rsync first anyway to get the remote up to date.
61
+ #
62
+ # Default: false
63
+ config.syncer.disable_up_rsync = false
64
+
57
65
  # Whether or not to show the file system events.
58
66
  # Default: false
59
67
  config.syncer.show_events = false
@@ -15,10 +15,9 @@ module Vagrant
15
15
  return if @exit_registered
16
16
 
17
17
  at_exit do
18
- if $!
19
- exit_status = $!.status
20
- exit exit_status if exit_status != 0
21
- end
18
+ exit 1 unless $!.is_a?(SystemExit)
19
+ exit_status = $!.status
20
+ exit exit_status if exit_status != 0
22
21
 
23
22
  # If vagrant up/reload/resume exited successfully, run rsync-auto.
24
23
  env[:machine].env.cli("rsync-auto")
@@ -46,8 +46,9 @@ module Vagrant
46
46
  next unless machine.communicate.ready?
47
47
  next unless synced_folders(machine)[:rsync]
48
48
 
49
- target_machine = Machine.new(machine)
50
- target_machine.full_sync if machine.ssh_info
49
+ if machine.ssh_info
50
+ Machine.new(machine).full_sync
51
+ end
51
52
  end
52
53
 
53
54
  return 0
@@ -37,7 +37,7 @@ module Vagrant
37
37
  argv = parse_options(opts)
38
38
  return unless argv
39
39
 
40
- listener_threads = []
40
+ machine_threads = []
41
41
 
42
42
  # Build up the paths that we need to listen to.
43
43
  with_target_vms(argv) do |machine|
@@ -56,11 +56,15 @@ module Vagrant
56
56
  next unless machine.communicate.ready?
57
57
  next unless synced_folders(machine)[:rsync]
58
58
 
59
- target_machine = Machine.new(machine, options[:poll])
60
- target_machine.full_sync if machine.ssh_info
61
- listener_threads << Thread.new { target_machine.listen }
59
+ if machine.ssh_info
60
+ target_machine = Machine.new(machine)
61
+ machine_threads << Thread.new do
62
+ target_machine.full_sync
63
+ target_machine.listen(options[:poll])
64
+ end
65
+ end
62
66
  end
63
- listener_threads.each { |t| t.join }
67
+ machine_threads.each { |t| t.join }
64
68
 
65
69
  return 0
66
70
  end
@@ -3,25 +3,28 @@ module Vagrant
3
3
  class Config < Vagrant.plugin(2, :config)
4
4
 
5
5
  attr_accessor \
6
+ :disable_up_rsync,
7
+ :force_listen_gem,
6
8
  :interval,
7
- :show_events,
8
- :ssh_args,
9
9
  :run_on_startup,
10
- :force_listen_gem
10
+ :show_events,
11
+ :ssh_args
11
12
 
12
13
  def initialize
14
+ @disable_up_rsync = UNSET_VALUE
15
+ @force_listen_gem = UNSET_VALUE
13
16
  @interval = UNSET_VALUE
17
+ @run_on_startup = UNSET_VALUE
14
18
  @show_events = UNSET_VALUE
15
19
  @ssh_args = UNSET_VALUE
16
- @run_on_startup = UNSET_VALUE
17
- @force_listen_gem = UNSET_VALUE
18
20
  end
19
21
 
20
22
  def finalize!
23
+ @disable_up_rsync = false if @disable_up_rsync == UNSET_VALUE
24
+ @force_listen_gem = false if @force_listen_gem == UNSET_VALUE
21
25
  @interval = 0.1 if @interval == UNSET_VALUE || @interval < 0.01
22
26
  @run_on_startup = true if @run_on_startup == UNSET_VALUE
23
27
  @show_events = false if @show_events == UNSET_VALUE
24
- @force_listen_gem = false if @force_listen_gem == UNSET_VALUE
25
28
 
26
29
  if @ssh_args = UNSET_VALUE
27
30
  @ssh_args = [
@@ -8,94 +8,97 @@ module Vagrant
8
8
 
9
9
  include Vagrant::Action::Builtin::MixinSyncedFolders
10
10
 
11
- def initialize(machine, polling=false)
12
- @paths = []
11
+ def initialize(machine)
12
+ @machine = machine
13
+ @logger = @machine.ui
14
+
15
+ @rsync_synced_folders = synced_folders(@machine)[:rsync]
16
+
13
17
  @syncers = []
14
- @excludes = []
15
- @logger = machine.ui
18
+ @rsync_synced_folders.each do |id, folder_opts|
19
+ @syncers << Syncers::Rsync.new(folder_opts, @machine)
20
+ end
21
+ end
16
22
 
17
- @listener_verbose = machine.config.syncer.show_events
18
- @listener_interval = machine.config.syncer.interval
23
+ def full_sync
24
+ @syncers.each do |syncer|
25
+ @logger.info(I18n.t('syncer.states.initial', {
26
+ host_path: syncer.host_path,
27
+ guest_path: syncer.guest_path
28
+ }))
29
+ syncer.sync([syncer.host_path], initial=true)
30
+ end
31
+ end
19
32
 
33
+ def listen(polling=false)
34
+ listener_excludes = []
35
+ listener_interval = @machine.config.syncer.interval
36
+ listener_verbose = @machine.config.syncer.show_events
37
+ listener_force_listen = @machine.config.syncer.force_listen_gem
20
38
  listener_settings = {
21
- latency: @listener_interval,
22
- wait_for_delay: @listener_interval / 2
39
+ latency: listener_interval,
40
+ wait_for_delay: listener_interval / 2
23
41
  }
24
42
 
25
43
  if polling
26
44
  require_relative 'listeners/listen'
27
- @listener_class = Vagrant::Syncer::Listeners::Listen
45
+ listener_class = Vagrant::Syncer::Listeners::Listen
28
46
  listener_settings[:force_polling] = polling
29
- elsif machine.config.syncer.force_listen_gem
47
+ elsif listener_force_listen
30
48
  require_relative 'listeners/listen'
31
- @listener_class = Vagrant::Syncer::Listeners::Listen
49
+ listener_class = Vagrant::Syncer::Listeners::Listen
32
50
  else
33
51
  case Vagrant::Util::Platform.platform
34
52
  when /darwin/
35
53
  require_relative 'listeners/fsevents'
36
- @listener_class = Vagrant::Syncer::Listeners::FSEvents
54
+ listener_class = Vagrant::Syncer::Listeners::FSEvents
37
55
  when /linux/
38
56
  require_relative 'listeners/inotify'
39
- @listener_class = Vagrant::Syncer::Listeners::INotify
57
+ listener_class = Vagrant::Syncer::Listeners::INotify
40
58
  else
41
59
  require_relative 'listeners/listen'
42
- @listener_class = Vagrant::Syncer::Listeners::Listen
60
+ listener_class = Vagrant::Syncer::Listeners::Listen
43
61
  end
44
62
  end
45
63
 
46
- @listener_name = @listener_class.to_s.gsub(/^.*::/, '')
64
+ paths = []
65
+ listener_excludes = []
66
+ @rsync_synced_folders.each do |id, folder_opts|
67
+ paths << File.expand_path(folder_opts[:hostpath],
68
+ @machine.env.root_path)
69
+ if folder_opts[:rsync__excludes]
70
+ listener_excludes << folder_opts[:rsync__excludes]
71
+ end
72
+ end
47
73
 
48
- rsync_synced_folders = synced_folders(machine)[:rsync]
74
+ listener_name = listener_class.to_s.gsub(/^.*::/, '')
49
75
 
50
- if rsync_synced_folders
51
- rsync_synced_folders.each do |id, folder_opts|
52
- @paths << File.expand_path(folder_opts[:hostpath], machine.env.root_path)
53
- @excludes << folder_opts[:rsync__excludes] if folder_opts[:rsync__excludes]
54
- @syncers << Syncers::Rsync.new(folder_opts, machine)
76
+ change_callback = Proc.new do |changed|
77
+ if listener_verbose
78
+ @logger.info(listener_name + ": " + changed.join(', '))
79
+ end
80
+ @syncers.each do |syncer|
81
+ syncer.sync(changed)
55
82
  end
56
83
  end
57
84
 
58
- @listener = @listener_class.new(
59
- @paths,
60
- @excludes,
85
+ listener = listener_class.new(
86
+ paths,
87
+ listener_excludes,
61
88
  listener_settings,
62
89
  change_callback
63
90
  )
64
- end
65
-
66
- def full_sync
67
- @syncers.each do |syncer|
68
- @logger.info(I18n.t('syncer.states.initial', {
69
- host_path: syncer.host_path,
70
- guest_path: syncer.guest_path
71
- }))
72
- syncer.sync([syncer.host_path], initial=true)
73
- end
74
- end
75
91
 
76
- def listen
77
- text = @listener_polling ? 'syncer.states.polling' : 'syncer.states.watching'
78
- @paths.each do |path|
92
+ text = polling ? 'syncer.states.polling' : 'syncer.states.watching'
93
+ paths.each do |path|
79
94
  @logger.info(I18n.t(text, {
80
95
  host_path: path,
81
- listener: @listener_name,
82
- interval: @listener_interval
96
+ listener: listener_name,
97
+ interval: listener_interval
83
98
  }))
84
99
  end
85
- @listener.run
86
- end
87
100
 
88
- private
89
-
90
- def change_callback
91
- Proc.new do |changed|
92
- if @listener_verbose
93
- @logger.info(@listener_name + ": " + changed.join(', '))
94
- end
95
- @syncers.each do |syncer|
96
- syncer.sync(changed)
97
- end
98
- end
101
+ listener.run
99
102
  end
100
103
 
101
104
  end
@@ -41,7 +41,9 @@ module Vagrant
41
41
  machine.ui.warn(I18n.t("vagrant.rsync_ssh_password"))
42
42
  end
43
43
 
44
- Machine.new(machine).full_sync
44
+ unless machine.config.syncer.disable_up_rsync
45
+ Machine.new(machine).full_sync
46
+ end
45
47
  end
46
48
  end
47
49
  end
@@ -1,5 +1,5 @@
1
1
  module Vagrant
2
2
  module Syncer
3
- VERSION = "1.1.8"
3
+ VERSION = "1.1.9"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-syncer
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.8
4
+ version: 1.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anssi Syrjäsalo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-20 00:00:00.000000000 Z
11
+ date: 2016-05-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler