Close TD-21 atomic write hardening

This commit is contained in:
2026-06-12 14:08:42 +02:00
parent a73af6b44d
commit 941db4c6f4
3 changed files with 63 additions and 2 deletions

View File

@@ -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),