blob: 967c6834f2c88d768d30f5910fb66490d7909426 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
|
module Hbc::Utils
module_function
def file_locked?(file)
unlocked = File.open(file).flock(File::LOCK_EX | File::LOCK_NB)
# revert lock if file was unlocked before check
File.open(file).flock(File::LOCK_UN) if unlocked
!unlocked
rescue
true
end
end
|