We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 87f6f0b commit f6b1d6bCopy full SHA for f6b1d6b
1 file changed
find-project-root/utils/lib/data/file.py
@@ -3,11 +3,9 @@
3
4
def atomic_write(file_path: Union[Path, str], data: str, encoding: str ='utf-8') -> None: # to prevent TOCTOU
5
import os
6
-
7
file_path = Path(file_path)
8
file_path.parent.mkdir(parents=True, exist_ok=True)
9
tmp_path = file_path.parent / f'.{file_path.name}.tmp'
10
11
try:
12
with open(tmp_path, 'w', encoding=encoding) as file:
13
file.write(data) ; file.flush() ; os.fsync(file.fileno())
0 commit comments