Skip to content

Commit

Permalink
328 - Ensure cleanup happens
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert A. Vincent II (Bob-Vee) committed Sep 30, 2022
1 parent 1a0ef7a commit 1de7888
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/puppet/provider/archive/ruby.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ def exists?
def create
transfer_download(archive_filepath) unless checksum?
extract
ensure
cleanup
end

Expand Down Expand Up @@ -140,7 +141,7 @@ def checksum?(store_checksum = true)
end

def cleanup
return unless extracted? && resource[:cleanup] == :true
return unless resource[:cleanup] == :true
Puppet.debug("Cleanup archive #{archive_filepath}")
destroy
end
Expand Down Expand Up @@ -195,12 +196,13 @@ def transfer_download(archive_filepath)
actual_checksum = archive.checksum(resource[:checksum_type])
if actual_checksum != checksum
destroy
FileUtils.rm_f(temppath) if File.exist?(temppath)
raise(Puppet::Error, "Download file checksum mismatch (expected: #{checksum} actual: #{actual_checksum})")
end
end

move_file_in_place(temppath, archive_filepath)
ensure
FileUtils.rm_f(temppath) if File.exist?(temppath)
end

def move_file_in_place(from, to)
Expand Down

0 comments on commit 1de7888

Please sign in to comment.