diff options
author | danielsdeleo <dan@opscode.com> | 2014-02-03 16:39:39 -0800 |
---|---|---|
committer | danielsdeleo <dan@opscode.com> | 2014-02-03 16:59:42 -0800 |
commit | d472efe27b3c9cd77902002f4158969d5d9eda15 (patch) | |
tree | dbfb51db144e9552a75083db87b2eb7cd4ae6253 | |
parent | cbfcd94aa2c1fc42c9e9e331a514d68668a7694a (diff) | |
download | chef-d472efe27b3c9cd77902002f4158969d5d9eda15.tar.gz |
Update file providers to close before unlinking.
This is required on windows, but the Tempfile implementation hides this
and silently ignores the error, meaning that we're leaving tempfiles
around on windows after we thought we'd cleaned them up. Eventually GC
would get to them, but this won't happen if there is a severe crash or
something calls `Kernel.exit!`, so we prefer to clean up manually.
-rw-r--r-- | lib/chef/provider/file.rb | 1 | ||||
-rw-r--r-- | spec/support/shared/unit/provider/file.rb | 1 |
2 files changed, 2 insertions, 0 deletions
diff --git a/lib/chef/provider/file.rb b/lib/chef/provider/file.rb index 3ef7725173..b6a20fe9b7 100644 --- a/lib/chef/provider/file.rb +++ b/lib/chef/provider/file.rb @@ -374,6 +374,7 @@ class Chef end # unlink necessary to clean up in why-run mode + tempfile.close tempfile.unlink end diff --git a/spec/support/shared/unit/provider/file.rb b/spec/support/shared/unit/provider/file.rb index 6562faca7c..02f68e0acc 100644 --- a/spec/support/shared/unit/provider/file.rb +++ b/spec/support/shared/unit/provider/file.rb @@ -483,6 +483,7 @@ shared_examples_for Chef::Provider::File do tempfile = double('Tempfile', :path => "/tmp/foo-bar-baz") content.stub(:tempfile).and_return(tempfile) File.should_receive(:exists?).with("/tmp/foo-bar-baz").and_return(true) + tempfile.should_receive(:close).once tempfile.should_receive(:unlink).once end |