summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsdelano <stephen@opscode.com>2012-12-12 16:01:19 -0800
committersdelano <stephen@opscode.com>2012-12-13 11:27:52 -0800
commit0a1c8a50a2f8949a75a631a463924ece92042cbb (patch)
treee1a32e7608f8fb9c1895a7c06f3604b57c0fcf45
parent855311ebae73ab36084009026d03a1afc61a0925 (diff)
downloadchef-0a1c8a50a2f8949a75a631a463924ece92042cbb.tar.gz
CHEF-3660: only monkeypatch on ruby 1.9 and earlier
-rw-r--r--chef/lib/chef/monkey_patches/fileutils.rb62
1 files changed, 32 insertions, 30 deletions
diff --git a/chef/lib/chef/monkey_patches/fileutils.rb b/chef/lib/chef/monkey_patches/fileutils.rb
index 4b2b24bb34..f18bead144 100644
--- a/chef/lib/chef/monkey_patches/fileutils.rb
+++ b/chef/lib/chef/monkey_patches/fileutils.rb
@@ -22,41 +22,43 @@
# patched in the trunk of Ruby, and this is a monkey patch of the offending
# code.
-require 'fileutils'
+unless RUBY_VERSION =~ /^2/
+ require 'fileutils'
-class FileUtils::Entry_
- def copy_metadata(path)
- st = lstat()
- if !st.symlink?
- File.utime st.atime, st.mtime, path
- end
- begin
- if st.symlink?
- begin
- File.lchown st.uid, st.gid, path
- rescue NotImplementedError
- end
- else
- File.chown st.uid, st.gid, path
+ class FileUtils::Entry_
+ def copy_metadata(path)
+ st = lstat()
+ if !st.symlink?
+ File.utime st.atime, st.mtime, path
end
- rescue Errno::EPERM
- # clear setuid/setgid
- if st.symlink?
- begin
- File.lchmod st.mode & 01777, path
- rescue NotImplementedError
+ begin
+ if st.symlink?
+ begin
+ File.lchown st.uid, st.gid, path
+ rescue NotImplementedError
+ end
+ else
+ File.chown st.uid, st.gid, path
end
- else
- File.chmod st.mode & 01777, path
- end
- else
- if st.symlink?
- begin
- File.lchmod st.mode, path
- rescue NotImplementedError
+ rescue Errno::EPERM
+ # clear setuid/setgid
+ if st.symlink?
+ begin
+ File.lchmod st.mode & 01777, path
+ rescue NotImplementedError
+ end
+ else
+ File.chmod st.mode & 01777, path
end
else
- File.chmod st.mode, path
+ if st.symlink?
+ begin
+ File.lchmod st.mode, path
+ rescue NotImplementedError
+ end
+ else
+ File.chmod st.mode, path
+ end
end
end
end