1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* lib/fileutils.rb: handle ENOENT error with symlink targeted to

non-exists file. [ruby-dev:45933] [Bug #6716]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46783 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
hsbt 2014-07-11 07:51:19 +00:00
parent 94bbd10ea7
commit c2eac0e78c
3 changed files with 20 additions and 3 deletions

View file

@ -1,3 +1,8 @@
Fri Jul 11 16:45:39 2014 SHIBATA Hiroshi <shibata.hiroshi@gmail.com>
* lib/fileutils.rb: handle ENOENT error with symlink targeted to
non-exists file. [ruby-dev:45933] [Bug #6716]
Fri Jul 11 15:59:42 2014 SHIBATA Hiroshi <shibata.hiroshi@gmail.com>
* array.c: Clarify documentation for Array#insert.

View file

@ -856,7 +856,8 @@ module FileUtils
fu_check_options options, OPT_TABLE['install']
fu_output_message "install -c#{options[:preserve] && ' -p'}#{options[:mode] ? (' -m 0%o' % options[:mode]) : ''} #{[src,dest].flatten.join ' '}" if options[:verbose]
return if options[:noop]
fu_each_src_dest(src, dest) do |s, d, st|
fu_each_src_dest(src, dest) do |s, d|
st = File.stat(s)
unless File.exist?(d) and compare_file(s, d)
remove_file d, true
copy_file s, d
@ -1242,7 +1243,12 @@ module FileUtils
end
def exist?
lstat! ? true : false
begin
lstat
true
rescue Errno::ENOENT
false
end
end
def file?
@ -1560,7 +1566,7 @@ module FileUtils
def fu_each_src_dest(src, dest) #:nodoc:
fu_each_src_dest0(src, dest) do |s, d|
raise ArgumentError, "same file: #{s} and #{d}" if fu_same?(s, d)
yield s, d, File.stat(s)
yield s, d
end
end
private_module_function :fu_each_src_dest

View file

@ -445,6 +445,12 @@ class TestFileUtils < Test::Unit::TestCase
assert_raise(Errno::ELOOP) {
mv 'tmp/symlink', 'tmp/symlink'
}
# unexist symlink
File.symlink 'xxx', 'tmp/src'
assert_nothing_raised {
mv 'tmp/src', 'tmp/dest'
}
assert_equal true, File.symlink?('tmp/dest')
end if have_symlink?
def test_mv_pathname