From 67e711998b321838c393d80ddf33dc37cf23c4b6 Mon Sep 17 00:00:00 2001 From: Brent Cook Date: Tue, 23 Jun 2015 12:04:12 -0500 Subject: [PATCH 1/2] Do not create the payloads.json file until first usage --- lib/rex/json_hash_file.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/rex/json_hash_file.rb b/lib/rex/json_hash_file.rb index 00556efdfe..59d1b42d2d 100644 --- a/lib/rex/json_hash_file.rb +++ b/lib/rex/json_hash_file.rb @@ -17,7 +17,6 @@ class JSONHashFile @hash = {} @last = 0 ::FileUtils.mkdir_p(::File.dirname(path)) - synced_update end def [](k) From 3141d4e465192b3832e579b695d2ad9a783cdd02 Mon Sep 17 00:00:00 2001 From: HD Moore Date: Tue, 23 Jun 2015 10:44:15 -0700 Subject: [PATCH 2/2] Relocate the mkdir to synced_update --- lib/rex/json_hash_file.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/rex/json_hash_file.rb b/lib/rex/json_hash_file.rb index 59d1b42d2d..fc282d057c 100644 --- a/lib/rex/json_hash_file.rb +++ b/lib/rex/json_hash_file.rb @@ -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