aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/cmd/cleanup.rb
diff options
context:
space:
mode:
authorJack Nagel2013-06-21 15:42:14 -0500
committerJack Nagel2013-06-21 15:42:14 -0500
commit68ebacb355c6baa0186d0002cc9700b506345bed (patch)
tree3d88ab44df1c514f9741d3ab15c0b4e0e1e2e1b6 /Library/Homebrew/cmd/cleanup.rb
parentc4cc4ccee4c7250f7385f7272d03a8a1ee2f3abc (diff)
downloadhomebrew-68ebacb355c6baa0186d0002cc9700b506345bed.tar.bz2
Clean up lockfiles
Diffstat (limited to 'Library/Homebrew/cmd/cleanup.rb')
-rw-r--r--Library/Homebrew/cmd/cleanup.rb13
1 files changed, 12 insertions, 1 deletions
diff --git a/Library/Homebrew/cmd/cleanup.rb b/Library/Homebrew/cmd/cleanup.rb
index c405c3efd..5cf7ef00e 100644
--- a/Library/Homebrew/cmd/cleanup.rb
+++ b/Library/Homebrew/cmd/cleanup.rb
@@ -10,7 +10,10 @@ module Homebrew extend self
if ARGV.named.empty?
cleanup_cellar
cleanup_cache
- rm_DS_Store unless ARGV.dry_run?
+ unless ARGV.dry_run?
+ cleanup_lockfiles
+ rm_DS_Store
+ end
else
ARGV.formulae.each { |f| cleanup_formula(f) }
end
@@ -80,6 +83,14 @@ module Homebrew extend self
end
end
+ def cleanup_lockfiles
+ candidates = HOMEBREW_CACHE_FORMULA.children
+ lockfiles = candidates.select { |f| f.file? && f.extname == '.brewing' }
+ lockfiles.select(&:readable?).each do |file|
+ file.open.flock(File::LOCK_EX | File::LOCK_NB) and file.unlink
+ end
+ end
+
def rm_DS_Store
system "find #{HOMEBREW_PREFIX} -name .DS_Store -delete 2>/dev/null"
end