Skip to content
Snippets Groups Projects
Commit a628c15a authored by Xu Cheng's avatar Xu Cheng
Browse files

lock keg during migration

parent b6c64ae4
No related branches found
No related tags found
No related merge requests found
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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment