Close TD-21 atomic write hardening
This commit is contained in:
1 parent
a73af6b44d
commit
941db4c6f4
3 files changed
+63
-2
No files matched your search
@@ -68,7 +68,7 @@ defmodule BDS.Persistence do
|
||||
def parse_timestamp(_value), do: nil
|
||||
|
||||
def atomic_write(path, contents) when is_binary(path) and is_binary(contents) do
|
||||
temp_path = path <> ".tmp"
|
||||
temp_path = path <> ".tmp." <> Integer.to_string(System.unique_integer([:positive]))
|
||||
|
||||
with :ok <- File.mkdir_p(Path.dirname(path)),
|
||||
:ok <- File.write(temp_path, contents),
|
||||
|
||||
Reference in new issue
Block a user