Skip to content

Commit

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

Expand Down Expand Up @@ -144,8 +145,7 @@ def checksum?(store_checksum = true)
end

def cleanup
return unless extracted? && resource[:cleanup] == :true

return unless resource[:cleanup] == :true and resource[:extract] == :true
Puppet.debug("Cleanup archive #{archive_filepath}")
destroy
end
Expand Down Expand Up @@ -201,12 +201,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 3331ced

Please sign in to comment.