utils/gems: make .homebrew_gem_groups writing atomic
This commit is contained in:
parent
0a6c5214ec
commit
a339b912c0
@ -191,7 +191,16 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
|
|
||||||
def write_user_gem_groups(groups)
|
def write_user_gem_groups(groups)
|
||||||
GEM_GROUPS_FILE.write(groups.join("\n"))
|
# Write the file atomically, in case we're working parallel
|
||||||
|
require "tempfile"
|
||||||
|
tmpfile = Tempfile.new([GEM_GROUPS_FILE.basename.to_s, "~"], GEM_GROUPS_FILE.dirname)
|
||||||
|
begin
|
||||||
|
tmpfile.write(groups.join("\n"))
|
||||||
|
tmpfile.close
|
||||||
|
File.rename(tmpfile.path.to_s, GEM_GROUPS_FILE)
|
||||||
|
ensure
|
||||||
|
tmpfile.unlink
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def forget_user_gem_groups!
|
def forget_user_gem_groups!
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user