Class: Vagrant::Syncer::SyncedFolder

Inherits:
Object
  • Object
show all
Includes:
Util
Defined in:
lib/syncer/synced_folder.rb

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ SyncedFolder

Returns a new instance of SyncedFolder.



10
11
12
13
14
# File 'lib/syncer/synced_folder.rb', line 10

def initialize(*args)
  super

  @logger = Log4r::Logger.new("vagrant::synced_folders::rsync")
end

Instance Method Details

#enable(machine, folders, opts) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/syncer/synced_folder.rb', line 27

def enable(machine, folders, opts)
  if machine.guest.capability?(:rsync_installed)
    installed = machine.guest.capability(:rsync_installed)
    if !installed
      can_install = machine.guest.capability?(:rsync_install)
      raise Vagrant::Errors::RSyncNotInstalledInGuest if !can_install
      machine.ui.info I18n.t("vagrant.rsync_installing")
      machine.guest.capability(:rsync_install)
    end
  end

  ssh_info = machine.ssh_info

  if ssh_info[:private_key_path].empty? && ssh_info[:password]
    machine.ui.warn(I18n.t("vagrant.rsync_ssh_password"))
  end

  unless machine.config.syncer.disable_up_rsync
    Machine.new(machine).full_sync
  end
end

#prepare(machine, folders, opts) ⇒ Object



23
24
25
# File 'lib/syncer/synced_folder.rb', line 23

def prepare(machine, folders, opts)
  # Nothing is necessary to do before VM boot.
end

#usable?(machine, raise_error = false) ⇒ Boolean

Returns:

  • (Boolean)

Raises:

  • (Vagrant::Errors::RSyncNotFound)


16
17
18
19
20
21
# File 'lib/syncer/synced_folder.rb', line 16

def usable?(machine, raise_error=false)
  rsync_path = Which.which("rsync")
  return true if rsync_path
  return false if !raise_error
  raise Vagrant::Errors::RSyncNotFound
end