summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/chef/provider/remote_file/ftp.rb1
-rw-r--r--lib/chef/provider/remote_file/http.rb2
-rw-r--r--lib/chef/provider/remote_file/local_file.rb2
-rw-r--r--spec/unit/provider/remote_file/http_spec.rb2
4 files changed, 4 insertions, 3 deletions
diff --git a/lib/chef/provider/remote_file/ftp.rb b/lib/chef/provider/remote_file/ftp.rb
index d75fb7a52c..7f3fdbf383 100644
--- a/lib/chef/provider/remote_file/ftp.rb
+++ b/lib/chef/provider/remote_file/ftp.rb
@@ -143,6 +143,7 @@ class Chef
ftp.voidcmd("TYPE #{typecode.upcase}")
end
ftp.getbinaryfile(filename, tempfile.path)
+ tempfile.close if tempfile
tempfile
end
diff --git a/lib/chef/provider/remote_file/http.rb b/lib/chef/provider/remote_file/http.rb
index 7eb2cda108..8949e6ab04 100644
--- a/lib/chef/provider/remote_file/http.rb
+++ b/lib/chef/provider/remote_file/http.rb
@@ -68,7 +68,7 @@ class Chef
raise e
end
end
-
+ tempfile.close if tempfile
tempfile
end
diff --git a/lib/chef/provider/remote_file/local_file.rb b/lib/chef/provider/remote_file/local_file.rb
index 8fa26d561d..b3b2301b81 100644
--- a/lib/chef/provider/remote_file/local_file.rb
+++ b/lib/chef/provider/remote_file/local_file.rb
@@ -38,7 +38,7 @@ class Chef
tempfile = Chef::FileContentManagement::Tempfile.new(new_resource).tempfile
Chef::Log.debug("#{new_resource} staging #{uri.path} to #{tempfile.path}")
FileUtils.cp(uri.path, tempfile.path)
- tempfile.close
+ tempfile.close if tempfile
tempfile
end
diff --git a/spec/unit/provider/remote_file/http_spec.rb b/spec/unit/provider/remote_file/http_spec.rb
index 9fbe76f68e..cb7271900d 100644
--- a/spec/unit/provider/remote_file/http_spec.rb
+++ b/spec/unit/provider/remote_file/http_spec.rb
@@ -159,7 +159,7 @@ describe Chef::Provider::RemoteFile::HTTP do
let(:tempfile_path) { "/tmp/chef-mock-tempfile-abc123" }
- let(:tempfile) { mock(Tempfile, :path => tempfile_path) }
+ let(:tempfile) { mock(Tempfile, :path => tempfile_path, :close => nil) }
let(:last_response) { {} }