Class: Vagrant::LXC::Action::RemoveTemporaryFiles

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-lxc/action/remove_temporary_files.rb

Instance Method Summary collapse

Constructor Details

#initialize(app, env) ⇒ RemoveTemporaryFiles

Returns a new instance of RemoveTemporaryFiles.



5
6
7
8
# File 'lib/vagrant-lxc/action/remove_temporary_files.rb', line 5

def initialize(app, env)
  @app    = app
  @logger = Log4r::Logger.new("vagrant::lxc::action::remove_tmp_files")
end

Instance Method Details

#call(env) ⇒ Object



10
11
12
13
14
15
16
17
18
19
# File 'lib/vagrant-lxc/action/remove_temporary_files.rb', line 10

def call(env)
  # Continue execution, we need the container to be stopped
  @app.call env

  if env[:machine].state.id == :stopped
    @logger.debug 'Removing temporary files'
    tmp_path = env[:machine].provider.driver.rootfs_path.join('tmp')
    env[:machine].provider.sudo_wrapper.run('rm', '-rf', "#{tmp_path}/*")
  end
end