summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLamont Granquist <lamont@opscode.com>2012-08-28 21:54:10 -0700
committerLamont Granquist <lamont@opscode.com>2012-08-28 21:54:10 -0700
commitd908e0b6d3d64c9b666d4986a77154f0b07e5b2d (patch)
treee9b735a3ddda6c3bc6b43925ebaf4cbfb3997907
parent9ff6247e77ec834ba306bc51dd6b356ff006f8d3 (diff)
downloadchef-d908e0b6d3d64c9b666d4986a77154f0b07e5b2d.tar.gz
fixing is_binary? bugs
-rw-r--r--chef/lib/chef/provider/file.rb9
1 files changed, 5 insertions, 4 deletions
diff --git a/chef/lib/chef/provider/file.rb b/chef/lib/chef/provider/file.rb
index ef9e424b04..0fa4894e10 100644
--- a/chef/lib/chef/provider/file.rb
+++ b/chef/lib/chef/provider/file.rb
@@ -58,7 +58,9 @@ class Chef
def is_binary?(path)
::File.open(path) do |file|
- file.read(Chef::Config[:diff_filesize_threshold]) !~ /^[[:print:]]*$/
+ buff = file.read(Chef::Config[:diff_filesize_threshold])
+ buff = "" if buff.nil?
+ return buff !~ /^[[:print:]]*$/
end
end
@@ -84,9 +86,8 @@ class Chef
end
# MacOSX(BSD?) diff will *sometimes* happily spit out nasty binary diffs
- if is_binary?(target_path) || is_binary?(temp_path)
- return [ "(binary files, diff output suppressed)" ]
- end
+ return [ "(current file is binary, diff output suppressed)"] if is_binary?(target_path)
+ return [ "(new content is binary, diff output suppressed)"] if is_binary?(temp_path)
begin
# -u: Unified diff format