Method: Azuki::Updater.wait_for_lock
- Defined in:
- lib/azuki/updater.rb
.wait_for_lock(path, wait_for = 5, check_every = 0.5) ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/azuki/updater.rb', line 54 def self.wait_for_lock(path, wait_for=5, check_every=0.5) start = Time.now.to_i while File.exists?(path) sleep check_every if (Time.now.to_i - start) > wait_for Azuki::Helpers.error "Unable to acquire update lock" end end begin FileUtils.touch path ret = yield ensure FileUtils.rm_f path end ret end |