locks: ensure lock directory exists

Fixes Homebrew/homebrew#17326.
This commit is contained in:
Jack Nagel 2013-01-26 13:18:44 -06:00
parent 2534c1d45e
commit 9a179d8b06
2 changed files with 2 additions and 0 deletions

View File

@ -229,6 +229,7 @@ class Formula
end
def lock
HOMEBREW_CACHE_FORMULA.mkpath
lockpath = HOMEBREW_CACHE_FORMULA/"#{@name}.brewing"
@lockfile = lockpath.open(File::RDWR | File::CREAT)
unless @lockfile.flock(File::LOCK_EX | File::LOCK_NB)

View File

@ -62,6 +62,7 @@ class Keg < Pathname
end
def lock
HOMEBREW_CACHE_FORMULA.mkpath
path = HOMEBREW_CACHE_FORMULA/"#{fname}.brewing"
file = path.open(File::RDWR | File::CREAT)
unless file.flock(File::LOCK_EX | File::LOCK_NB)