atomic_write: create path before writing file
This commit is contained in:
parent
bdcc3e2be5
commit
a03bb44e10
@ -19,6 +19,10 @@ class Registry
|
||||
end
|
||||
|
||||
def atomic_write(path, content)
|
||||
dir = File.dirname(path)
|
||||
unless Dir.exist?(dir)
|
||||
FileUtils.mkdir_p(dir)
|
||||
end
|
||||
temp_path = path.to_s + ".tmp"
|
||||
File.open(temp_path, 'w+') do |f|
|
||||
f.write(content)
|
||||
|
Loading…
Reference in New Issue
Block a user