mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* lib/fileutils.rb (copy_metadata): use File.lchown and File.lchmod to
update meta data of symlinks. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35499 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
c40e6f8257
commit
7d89ecdc52
3 changed files with 43 additions and 4 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
Mon Apr 30 23:36:49 2012 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
|
* lib/fileutils.rb (copy_metadata): use File.lchown and File.lchmod to
|
||||||
|
update meta data of symlinks.
|
||||||
|
|
||||||
Mon Apr 30 23:05:53 2012 CHIKANAGA Tomoyuki <nagachika00@gmail.com>
|
Mon Apr 30 23:05:53 2012 CHIKANAGA Tomoyuki <nagachika00@gmail.com>
|
||||||
|
|
||||||
* test/ruby/test_continuation.rb (tracing_with_set_trace_func): don't
|
* test/ruby/test_continuation.rb (tracing_with_set_trace_func): don't
|
||||||
|
|
|
@ -1444,14 +1444,37 @@ private
|
||||||
|
|
||||||
def copy_metadata(path)
|
def copy_metadata(path)
|
||||||
st = lstat()
|
st = lstat()
|
||||||
File.utime st.atime, st.mtime, path
|
if !st.symlink?
|
||||||
|
File.utime st.atime, st.mtime, path
|
||||||
|
end
|
||||||
begin
|
begin
|
||||||
File.chown st.uid, st.gid, path
|
if st.symlink?
|
||||||
|
begin
|
||||||
|
File.lchown st.uid, st.gid, path
|
||||||
|
rescue NotImplementedError
|
||||||
|
end
|
||||||
|
else
|
||||||
|
File.chown st.uid, st.gid, path
|
||||||
|
end
|
||||||
rescue Errno::EPERM
|
rescue Errno::EPERM
|
||||||
# clear setuid/setgid
|
# clear setuid/setgid
|
||||||
File.chmod st.mode & 01777, path
|
if st.symlink?
|
||||||
|
begin
|
||||||
|
File.lchmod st.mode & 01777, path
|
||||||
|
rescue NotImplementedError
|
||||||
|
end
|
||||||
|
else
|
||||||
|
File.chmod st.mode & 01777, path
|
||||||
|
end
|
||||||
else
|
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
|
end
|
||||||
|
|
||||||
|
|
|
@ -325,6 +325,17 @@ class TestFileUtils
|
||||||
assert_equal 'SLdest', File.readlink('tmp/cpr_dest2/symlink')
|
assert_equal 'SLdest', File.readlink('tmp/cpr_dest2/symlink')
|
||||||
end if have_symlink?
|
end if have_symlink?
|
||||||
|
|
||||||
|
def test_cp_r_symlink_preserve
|
||||||
|
mkdir 'tmp/cross'
|
||||||
|
mkdir 'tmp/cross/a'
|
||||||
|
mkdir 'tmp/cross/b'
|
||||||
|
touch 'tmp/cross/a/f'
|
||||||
|
touch 'tmp/cross/b/f'
|
||||||
|
ln_s '../a/f', 'tmp/cross/b/l'
|
||||||
|
ln_s '../b/f', 'tmp/cross/a/l'
|
||||||
|
cp_r 'tmp/cross', 'tmp/cross2', :preserve => true
|
||||||
|
end if have_symlink?
|
||||||
|
|
||||||
def test_cp_r_pathname
|
def test_cp_r_pathname
|
||||||
# pathname
|
# pathname
|
||||||
touch 'tmp/cprtmp'
|
touch 'tmp/cprtmp'
|
||||||
|
|
Loading…
Reference in a new issue