aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/keg.rb
diff options
context:
space:
mode:
authorJack Nagel2014-07-12 19:56:58 -0500
committerJack Nagel2014-07-12 19:56:58 -0500
commit398964e747a5eaa9e9a099d3fc47c3a4e9badba2 (patch)
treee680c705962dbbc0ddb63376b1e8d4165720226c /Library/Homebrew/keg.rb
parentd2d257af4a223144f2b9c8310fad82758c211e89 (diff)
downloadhomebrew-398964e747a5eaa9e9a099d3fc47c3a4e9badba2.tar.bz2
Handle conflicts where links point at symlinks
Fixes #30664.
Diffstat (limited to 'Library/Homebrew/keg.rb')
-rw-r--r--Library/Homebrew/keg.rb11
1 files changed, 6 insertions, 5 deletions
diff --git a/Library/Homebrew/keg.rb b/Library/Homebrew/keg.rb
index 45aab7eb4..9b9625fbc 100644
--- a/Library/Homebrew/keg.rb
+++ b/Library/Homebrew/keg.rb
@@ -322,11 +322,12 @@ class Keg
private
def resolve_any_conflicts dst, mode
- # if it isn't a directory then a severe conflict is about to happen. Let
- # it, and the exception that is generated will message to the user about
- # the situation
- if dst.symlink? and dst.directory?
- src = dst.resolved_path
+ src = dst.resolved_path
+ # src itself may be a symlink, so check lstat to ensure we are dealing with
+ # a directory, and not a symlink pointing at a directory (which needs to be
+ # treated as a file). In other words, we onlly want to resolve one symlink.
+ # If it isn't a directory, make_relative_symlink will raise an exception.
+ if dst.symlink? && src.lstat.directory?
keg = Keg.for(src)
dst.unlink unless mode.dry_run
keg.link_dir(src, mode) { :mkpath }