Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Ensure mount points are discarded when template build fails

  • Loading branch information...
commit db4f9c8158e76b7604fbafdbd90c1ac8756c0ace 1 parent 3e2070a
@zeha zeha authored
Showing with 12 additions and 2 deletions.
  1. +12 −2 lib/template_archive_builder.rb
View
14 lib/template_archive_builder.rb
@@ -16,8 +16,18 @@ def initialize(opts = {})
def build
Dir.mktmpdir do |workdir|
- @workdir = workdir
- build_internal
+ begin
+ @workdir = workdir
+ build_internal
+ ensure
+ # umount all submounts
+ mounts = File.read("/proc/mounts").split("\n").map { |l|
+ l.split[1][0, @workdir.length] == @workdir ? l.split[1] : nil
+ }.compact
+ mounts.each do |path|
+ %x{umount #{path}}
+ end
+ end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.