From 71db7bd3d3c87a5390a54a409de06d672ca32b98 Mon Sep 17 00:00:00 2001 From: nobu Date: Mon, 27 Jun 2016 01:24:46 +0000 Subject: Refactor * lib/fileutils.rb (FileUtils::Entry_#copy_metadata): eliminate common statements. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55511 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/fileutils.rb | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) (limited to 'lib') diff --git a/lib/fileutils.rb b/lib/fileutils.rb index de8474f2d0..a7fca26dbb 100644 --- a/lib/fileutils.rb +++ b/lib/fileutils.rb @@ -1273,6 +1273,7 @@ module FileUtils if !st.symlink? File.utime st.atime, st.mtime, path end + mode = st.mode begin if st.symlink? begin @@ -1284,23 +1285,15 @@ module FileUtils end 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 + mode &= 01777 + end + if st.symlink? + begin + File.lchmod mode, path + rescue NotImplementedError end else - if st.symlink? - begin - File.lchmod st.mode, path - rescue NotImplementedError - end - else - File.chmod st.mode, path - end + File.chmod mode, path end end -- cgit v1.2.3