Class: VagrantPlugins::WinAzure::Action::SyncFolders

Inherits:
Vagrant::Action::Builtin::SyncedFolders
  • Object
show all
Includes:
Vagrant::Util::ScopedHashOverride
Defined in:
lib/vagrant-azure/action/sync_folders.rb

Overview

This middleware uses ‘rsync` to sync the folders

Instance Method Summary collapse

Constructor Details

#initialize(app, env) ⇒ SyncFolders

Returns a new instance of SyncFolders.



21
22
23
24
# File 'lib/vagrant-azure/action/sync_folders.rb', line 21

def initialize(app, env)
  @app    = app
  @logger = Log4r::Logger.new("vagrant_azure::action::sync_folders")
end

Instance Method Details

#call(env) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/vagrant-azure/action/sync_folders.rb', line 26

def call(env)
  if env[:machine].config.vm.guest != :windows
    super
  else
    @app.call(env)
    env[:machine].config.vm.synced_folders.each do |id, data|
      data = scoped_hash_override(data, :azure)

      # Ignore disabled shared folders
      next if data[:disabled]

      hostpath  = File.expand_path(data[:hostpath], env[:root_path])
      guestpath = data[:guestpath]

      env[:ui].info(I18n.t("vagrant_azure.copy_folder",
                          :hostpath => hostpath,
                          :guestpath => guestpath))

      # Create the host path if it doesn't exist and option flag is set
      if data[:create]
        begin
          FileUtils::mkdir_p(hostpath)
        rescue => err
          raise Errors::MkdirError,
            :hostpath => hostpath,
            :err => err
        end
      end

      env[:machine].communicate.upload(hostpath, guestpath)

    end
  end
end