Clean Up Dir..

This commit is contained in:
Jan Renz
2015-04-28 11:14:33 +02:00
parent 0447b076c6
commit 89c851b24f

View File

@ -83,7 +83,7 @@ class DockerClient
Rails.logger.info('destroying container ' + container.to_s)
container.stop.kill
container.port_bindings.values.each { |port| PortPool.release(port) }
FileUtils.rm_rf(local_workspace_path(container)) if local_workspace_path(container)
Pathname.new(local_workspace_path).children.each{ |p| p.rmtree} if local_workspace_path(container)
container.delete(force: true)
end
@ -94,6 +94,8 @@ class DockerClient
def execute_command(command, before_execution_block, output_consuming_block)
#tries ||= 0
@container = DockerContainerPool.get_container(@execution_environment)
#clear directory (it should be emtpy anyhow)
Pathname.new(local_workspace_path).children.each{ |p| p.rmtree}
if @container
before_execution_block.try(:call)
send_command(command, @container, &output_consuming_block)
@ -167,9 +169,7 @@ class DockerClient
def return_container(container)
local_workspace_path = self.class.local_workspace_path(container)
#FileUtils.rm_rf(local_workspace_path) if local_workspace_path
Pathname.new(local_workspace_path).children.each{ |p| p.rmtree}
#FileUtils.mkdir(local_workspace_path)
DockerContainerPool.return_container(container, @execution_environment)
end
private :return_container
@ -202,5 +202,6 @@ class DockerClient
end
private :send_command
class Error < RuntimeError; end
end