Sha256: fd49271a76dda8dc238f54c78a40bcd8b46e3a6e774d0c83d49e4d4790b70792

Contents?: true

Size: 801 Bytes

Versions: 3

Compression:

Stored size: 801 Bytes

Contents

require 'log4r'

module VagrantPlugins
  module ProviderLibvirt
    module Action
      class CleanMachineFolder

        def initialize(app, env, options=nil)
          @logger = Log4r::Logger.new('vagrant_libvirt::action::create_domain')
          @app = app
          @ui = env[:ui]
          @quiet = (options || {}).fetch(:quiet, false)
        end

        def call(env)
          machine_folder = env[:machine].data_dir

          @ui.info("Deleting the machine folder") unless @quiet

          @logger.debug("Recursively removing: #{machine_folder}")
          FileUtils.rm_rf(machine_folder, :secure => true)
          # need to recreate to prevent exception during a cancelled up
          FileUtils.mkdir_p(machine_folder)

          @app.call(env)
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
vagrant-libvirt-0.5.3 lib/vagrant-libvirt/action/clean_machine_folder.rb
vagrant-libvirt-0.5.2 lib/vagrant-libvirt/action/clean_machine_folder.rb
vagrant-libvirt-0.5.1 lib/vagrant-libvirt/action/clean_machine_folder.rb