Skip to content

Commit 71225b1

Browse files
committed
Just the parent path of the destination symlink should exist
1 parent 9618ce5 commit 71225b1

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

lib/fileutils.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -739,7 +739,7 @@ def ln_sr(src, dest, target_directory: true, force: nil, noop: nil, verbose: nil
739739
real_ddirs = fu_split_path(File.realpath(parent))
740740
else
741741
destdirs ||= fu_split_path(dest)
742-
real_ddirs ||= fu_split_path(File.realpath(dest))
742+
real_ddirs ||= fu_split_path(File.realdirpath(dest))
743743
end
744744
srcdirs = fu_split_path(s)
745745
i = fu_common_components(srcdirs, destdirs)

test/fileutils/test_fileutils.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1080,7 +1080,11 @@ def test_ln_sr_not_target_directory
10801080
assert_raise(Errno::EEXIST, Errno::EACCES) {
10811081
ln_sr fname, 'tmp', target_directory: false
10821082
}
1083-
assert_file.not_exist? File.join('tmp/', File.basename(fname))
1083+
dest = File.join('tmp/', File.basename(fname))
1084+
assert_file.not_exist? dest
1085+
ln_sr fname, dest, target_directory: false
1086+
assert_file.symlink?(dest)
1087+
assert_equal("../#{fname}", File.readlink(dest))
10841088
end
10851089
end if have_symlink?
10861090

0 commit comments

Comments
 (0)