10000 merge revision(s) r46783: [Backport #6716] · github/ruby@b3cfa2f · GitHub
[go: up one dir, main page]

Skip to content

Commit b3cfa2f

Browse files
committed
merge revision(s) r46783: [Backport ruby#6716]
* lib/fileutils.rb: handle ENOENT error with symlink targeted to non-exists file. [ruby-dev:45933] [Bug ruby#6716] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@47953 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
1 parent 39fcf33 commit b3cfa2f

File tree

4 files changed

+21
-4
lines changed

4 files changed

+21
-4
lines changed

ChangeLog

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
Wed Oct 15 23:50:33 2014 SHIBATA Hiroshi <shibata.hiroshi@gmail.com>
2+
3+
* lib/fileutils.rb: handle ENOENT error with symlink targeted to
4+
non-exists file. [ruby-dev:45933] [Bug #6716]
5+
16
Wed Oct 15 23:25:24 2014 NARUSE, Yui <naruse@ruby-lang.org>
27

38
* configure.in: NetBSD's ksh, used by configure, needs escapes.

lib/fileutils.rb

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -854,7 +854,8 @@ def install(src, dest, options = {})
854854
fu_check_options options, OPT_TABLE['install']
855855
fu_output_message "install -c#{options[:preserve] && ' -p'}#{options[:mode] ? (' -m 0%o' % options[:mode]) : ''} #{[src,dest].flatten.join ' '}" if options[:verbose]
856856
return if options[:noop]
857-
fu_each_src_dest(src, dest) do |s, d, st|
857+
fu_each_src_dest(src, dest) do |s, d|
858+
st = File.stat(s)
858859
unless File.exist?(d) and compare_file(s, d)
859860
remove_file d, true
860861
copy_file s, d
@@ -1252,7 +1253,12 @@ def dereference?
12521253
end
12531254

12541255
def exist?
1255-
lstat! ? true : false
1256+
begin
1257+
lstat
1258+
true
1259+
rescue Errno::ENOENT
1260+
false
1261+
end
12561262
end
12571263

12581264
def file?
@@ -1570,7 +1576,7 @@ def fu_list(arg) #:nodoc:
15701576
def fu_each_src_dest(src, dest) #:nodoc:
15711577
fu_each_src_dest0(src, dest) do |s, d|
15721578
raise ArgumentError, "same file: #{s} and #{d}" if fu_same?(s, d)
1573-
yield s, d, File.stat(s)
1579+
yield s, d
15741580
end
15751581
end
15761582
private_module_function :fu_each_src_dest

test/fileutils/test_fileutils.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,12 @@ def test_mv_symlink
420420
assert_raise(Errno::ELOOP) {
421421
mv 'tmp/symlink', 'tmp/symlink'
422422
}
423+
# unexist symlink
424+
File.symlink 'xxx', 'tmp/src'
425+
assert_nothing_raised {
426+
mv 'tmp/src', 'tmp/dest'
427+
}
428+
assert_equal true, File.symlink?('tmp/dest')
423429
end if have_symlink?
424430

425431
def test_mv_pathname

version.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#define RUBY_VERSION "2.1.4"
22
#define RUBY_RELEASE_DATE "2014-10-15"
3-
#define RUBY_PATCHLEVEL 253
3+
#define RUBY_PATCHLEVEL 254
44

55
#define RUBY_RELEASE_YEAR 2014
66
#define RUBY_RELEASE_MONTH 10

0 commit comments

Comments
 (0)
0