diff options
| author | Xu Cheng | 2015-08-17 22:49:57 +0800 |
|---|---|---|
| committer | Xu Cheng | 2015-08-20 15:47:42 +0800 |
| commit | a628c15afde8fb1bcf441b9737df908821fc6873 (patch) | |
| tree | e821669ea79ea6a552524f8bf73027b9f0c72261 /Library | |
| parent | b6c64ae46a2eafd27057ea2bca724186bf7ddc13 (diff) | |
| download | brew-a628c15afde8fb1bcf441b9737df908821fc6873.tar.bz2 | |
lock keg during migration
Diffstat (limited to 'Library')
| -rw-r--r-- | Library/Homebrew/migrator.rb | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/Library/Homebrew/migrator.rb b/Library/Homebrew/migrator.rb index 82af17f02..2ab5fc295 100644 --- a/Library/Homebrew/migrator.rb +++ b/Library/Homebrew/migrator.rb @@ -1,4 +1,5 @@ require "formula" +require "formula_lock" require "keg" require "tab" require "tap_migrations" @@ -132,6 +133,7 @@ class Migrator begin oh1 "Migrating #{Tty.green}#{oldname}#{Tty.white} to #{Tty.green}#{newname}#{Tty.reset}" + lock unlink_oldname move_to_new_directory repin @@ -147,6 +149,8 @@ class Migrator puts e.backtrace if ARGV.debug? puts "Backuping..." ignore_interrupts { backup_oldname } + ensure + unlock end end @@ -320,4 +324,16 @@ class Migrator def backup_old_tabs old_tabs.each(&:write) end + + def lock + @newname_lock = FormulaLock.new newname + @oldname_lock = FormulaLock.new oldname + @newname_lock.lock + @oldname_lock.lock + end + + def unlock + @newname_lock.unlock + @oldname_lock.unlock + end end |
