summaryrefslogtreecommitdiff
path: root/lib/chef/file_content_management/tempfile.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/chef/file_content_management/tempfile.rb')
-rw-r--r--lib/chef/file_content_management/tempfile.rb8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/chef/file_content_management/tempfile.rb b/lib/chef/file_content_management/tempfile.rb
index bba4b34d82..f7d0bd315f 100644
--- a/lib/chef/file_content_management/tempfile.rb
+++ b/lib/chef/file_content_management/tempfile.rb
@@ -40,7 +40,7 @@ class Chef
tempfile_dirnames.each do |tempfile_dirname|
begin
- tf = ::Tempfile.open(tempfile_basename, tempfile_dirname)
+ tf = ::Tempfile.open([tempfile_basename, tempfile_extension], tempfile_dirname)
break
rescue SystemCallError => e
message = "Creating temp file under '#{tempfile_dirname}' failed with: '#{e.message}'"
@@ -63,12 +63,16 @@ class Chef
# as the arguments to Tempfile.new() consistently.
#
def tempfile_basename
- basename = ::File.basename(@new_resource.name)
+ basename = ::File.basename(@new_resource.name, File.extname(@new_resource.name))
basename.insert 0, "chef-"
basename.insert 0, "." unless Chef::Platform.windows? # dotfile if we're not on windows
basename
end
+ def tempfile_extension
+ File.extname(@new_resource.name)
+ end
+
# Returns the possible directories for the tempfile to be created in.
def tempfile_dirnames
# in why-run mode we need to create a Tempfile to compare against, which we will never