diff options
author | adamedx <adamed@opscode.com> | 2013-10-17 10:10:31 -0700 |
---|---|---|
committer | adamedx <adamed@opscode.com> | 2013-10-17 11:56:08 -0700 |
commit | 25f40030304b178f7e5518bf6da290245bc05c10 (patch) | |
tree | 1dbe3f90e0c8c920086acc4c29131e37f1ecb209 | |
parent | 9bb1c68605f1bf2db5c67f9b20ec7e4990a4ee2f (diff) | |
download | chef-25f40030304b178f7e5518bf6da290245bc05c10.tar.gz |
Handle nil tempfile, ftp, http cases
-rw-r--r-- | lib/chef/provider/remote_file/ftp.rb | 1 | ||||
-rw-r--r-- | lib/chef/provider/remote_file/http.rb | 2 | ||||
-rw-r--r-- | lib/chef/provider/remote_file/local_file.rb | 2 | ||||
-rw-r--r-- | spec/unit/provider/remote_file/http_spec.rb | 2 |
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) { {} } |