Don't error if exact link already exists

If the link already exists exactly (well almost exactly) as we are about to correct it, then it's okay. Otherwise we error out. This is a safe choice, and really, the correct choice too.

This will prevent the tickets like Homebrew/homebrew#11050 from occurring.
This commit is contained in:
Max Howell 2012-03-19 12:24:13 +00:00
parent c3370c48ce
commit 88118b51b2
2 changed files with 18 additions and 5 deletions

View File

@ -10,6 +10,11 @@ module Homebrew extend self
end
ARGV.kegs.each do |keg|
if keg.linked_keg_record.directory? and keg.linked_keg_record.realpath == keg
opoo "Already linked: #{keg}"
next
end
print "Linking #{keg}... " do
puts if ARGV.verbose?
puts "#{keg.link} symlinks created"

View File

@ -102,9 +102,9 @@ class Keg < Pathname
end
end
(HOMEBREW_REPOSITORY/"Library/LinkedKegs"/fname).make_relative_symlink(self)
linked_keg_record.make_relative_symlink(self)
return $n+$d
return $n + $d
end
protected
@ -123,6 +123,14 @@ protected
puts "Won't resolve conflicts for symlink #{dst} as it doesn't resolve into the Cellar" if ARGV.verbose?
end
def make_relative_symlink dst, src
if dst.exist? and dst.realpath == src.realpath
puts "Skipping; already exists: #{dst}" if ARGV.verbose?
else
dst.make_relative_symlink src
end
end
# symlinks the contents of self+foo recursively into /usr/local/foo
def link_dir foo
root = self+foo
@ -141,10 +149,10 @@ protected
when :skip_file
Find.prune
when :info
dst.make_relative_symlink(src)
make_relative_symlink dst, src
dst.install_info
else
dst.make_relative_symlink(src)
make_relative_symlink dst, src
end
elsif src.directory?
# if the dst dir already exists, then great! walk the rest of the tree tho
@ -161,7 +169,7 @@ protected
dst.mkpath unless resolve_any_conflicts(dst)
else
unless resolve_any_conflicts(dst)
dst.make_relative_symlink(src)
make_relative_symlink dst, src
Find.prune
end
end