lock keg during migration
This commit is contained in:
parent
b6c64ae46a
commit
a628c15afd
@ -1,4 +1,5 @@
|
|||||||
require "formula"
|
require "formula"
|
||||||
|
require "formula_lock"
|
||||||
require "keg"
|
require "keg"
|
||||||
require "tab"
|
require "tab"
|
||||||
require "tap_migrations"
|
require "tap_migrations"
|
||||||
@ -132,6 +133,7 @@ class Migrator
|
|||||||
|
|
||||||
begin
|
begin
|
||||||
oh1 "Migrating #{Tty.green}#{oldname}#{Tty.white} to #{Tty.green}#{newname}#{Tty.reset}"
|
oh1 "Migrating #{Tty.green}#{oldname}#{Tty.white} to #{Tty.green}#{newname}#{Tty.reset}"
|
||||||
|
lock
|
||||||
unlink_oldname
|
unlink_oldname
|
||||||
move_to_new_directory
|
move_to_new_directory
|
||||||
repin
|
repin
|
||||||
@ -147,6 +149,8 @@ class Migrator
|
|||||||
puts e.backtrace if ARGV.debug?
|
puts e.backtrace if ARGV.debug?
|
||||||
puts "Backuping..."
|
puts "Backuping..."
|
||||||
ignore_interrupts { backup_oldname }
|
ignore_interrupts { backup_oldname }
|
||||||
|
ensure
|
||||||
|
unlock
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -320,4 +324,16 @@ class Migrator
|
|||||||
def backup_old_tabs
|
def backup_old_tabs
|
||||||
old_tabs.each(&:write)
|
old_tabs.each(&:write)
|
||||||
end
|
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
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user