diff options
| author | Markus Reiter | 2017-05-22 04:15:11 +0200 |
|---|---|---|
| committer | Markus Reiter | 2017-05-25 06:18:52 +0200 |
| commit | fd97e88b990b4804e9cfec90e3e5fe60fa54437a (patch) | |
| tree | c32ba2c02e01d1b605021d5301e5e9c4c9e70527 /Library/Homebrew/cask/lib/hbc/cli | |
| parent | 060af0a26ab7219e46b500fd1c7f420b6cc74cbb (diff) | |
| download | brew-fd97e88b990b4804e9cfec90e3e5fe60fa54437a.tar.bz2 | |
Use `LockFile` instead of `Hbc::Utils::file_locked?`.
Diffstat (limited to 'Library/Homebrew/cask/lib/hbc/cli')
| -rw-r--r-- | Library/Homebrew/cask/lib/hbc/cli/cleanup.rb | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/Library/Homebrew/cask/lib/hbc/cli/cleanup.rb b/Library/Homebrew/cask/lib/hbc/cli/cleanup.rb index e25393230..40b37dd5d 100644 --- a/Library/Homebrew/cask/lib/hbc/cli/cleanup.rb +++ b/Library/Homebrew/cask/lib/hbc/cli/cleanup.rb @@ -75,14 +75,18 @@ module Hbc paths.each do |item| next unless item.exist? processed_files += 1 - if Utils.file_locked?(item) + + begin + LockFile.new(item.basename).with_lock do + puts item + item_size = File.size?(item) + cleanup_size += item_size unless item_size.nil? + item.unlink + end + rescue OperationInProgressError puts "skipping: #{item} is locked" next end - puts item - item_size = File.size?(item) - cleanup_size += item_size unless item_size.nil? - item.unlink end if processed_files.zero? |
