diff --git a/lib/rex/json_hash_file.rb b/lib/rex/json_hash_file.rb index 00556efdfe..fc282d057c 100644 --- a/lib/rex/json_hash_file.rb +++ b/lib/rex/json_hash_file.rb @@ -16,8 +16,6 @@ class JSONHashFile @lock = Mutex.new @hash = {} @last = 0 - ::FileUtils.mkdir_p(::File.dirname(path)) - synced_update end def [](k) @@ -53,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) @@ -81,7 +80,6 @@ private end end - def parse_data(data) return {} if data.to_s.strip.length == 0 begin