Permalink
Browse files

FIX #6716 https://bugs.ruby-lang.org/issues/6716

  • Loading branch information...
1 parent dea5824 commit 00a677d8f42a36dc3ec5515fde8107e5f41bfd7b @tmtm committed Jul 11, 2012
Showing with 15 additions and 3 deletions.
  1. +9 −3 lib/fileutils.rb
  2. +6 −0 test/fileutils/test_fileutils.rb
View
@@ -925,7 +925,8 @@ def install(src, dest, options = {})
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
@@ -1295,7 +1296,12 @@ def dereference?
end
def exist?
- lstat! ? true : false
+ begin
+ lstat
+ true
+ rescue Errno::ENOENT
+ false
+ end
end
def file?
@@ -1604,7 +1610,7 @@ def fu_list(arg) #:nodoc:
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
@@ -396,6 +396,12 @@ def test_mv_symlink
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

0 comments on commit 00a677d

Please sign in to comment.