Skip to content

Commit 3141d4e

Browse files
author
HD Moore
committed
Relocate the mkdir to synced_update
1 parent 67e7119 commit 3141d4e

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

lib/rex/json_hash_file.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ def initialize(path)
1616
@lock = Mutex.new
1717
@hash = {}
1818
@last = 0
19-
::FileUtils.mkdir_p(::File.dirname(path))
2019
end
2120

2221
def [](k)
@@ -52,6 +51,7 @@ def clear
5251
# Save the file, but prevent thread & process contention
5352
def synced_update(&block)
5453
@lock.synchronize do
54+
::FileUtils.mkdir_p(::File.dirname(path))
5555
::File.open(path, ::File::RDWR|::File::CREAT) do |fd|
5656
fd.flock(::File::LOCK_EX)
5757

@@ -80,7 +80,6 @@ def synced_update(&block)
8080
end
8181
end
8282

83-
8483
def parse_data(data)
8584
return {} if data.to_s.strip.length == 0
8685
begin

0 commit comments

Comments
 (0)