diff options
Diffstat (limited to 'Library/Homebrew/formula.rb')
| -rw-r--r-- | Library/Homebrew/formula.rb | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index 2e072afff..e2fde2ef9 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -228,6 +228,21 @@ class Formula end end + def lock + lockpath = HOMEBREW_CACHE_FORMULA/"#{@name}.brewing" + @lockfile = lockpath.open(File::RDWR | File::CREAT) + unless @lockfile.flock(File::LOCK_EX | File::LOCK_NB) + raise OperationInProgressError, @name + end + end + + def unlock + unless @lockfile.nil? + @lockfile.flock(File::LOCK_UN) + @lockfile.close + end + end + def == b name == b.name end |
