Relocate the mkdir to synced_update

bug/bundler_fix
HD Moore 2015-06-23 10:44:15 -07:00
parent 67e711998b
commit 3141d4e465
1 changed files with 1 additions and 2 deletions

View File

@ -16,7 +16,6 @@ class JSONHashFile
@lock = Mutex.new
@hash = {}
@last = 0
::FileUtils.mkdir_p(::File.dirname(path))
end
def [](k)
@ -52,6 +51,7 @@ private
# Save the file, but prevent thread & process contention
def synced_update(&block)
@lock.synchronize do
::FileUtils.mkdir_p(::File.dirname(path))
::File.open(path, ::File::RDWR|::File::CREAT) do |fd|
fd.flock(::File::LOCK_EX)
@ -80,7 +80,6 @@ private
end
end
def parse_data(data)
return {} if data.to_s.strip.length == 0
begin