mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 10:44:09 -04:00
Use a prefix for the atomic write tempfile
This commit is contained in:
parent
3e97ae74d6
commit
65219abb3d
@ -375,7 +375,7 @@ def commit_data(file_path, data):
|
||||
bdir = os.path.dirname(file_path)
|
||||
os.makedirs(bdir, exist_ok=True, mode=CONFIG_DIR_MODE)
|
||||
try:
|
||||
with tempfile.NamedTemporaryFile(dir=bdir, delete=False) as f:
|
||||
with tempfile.NamedTemporaryFile(dir=bdir, prefix=os.path.basename(file_path).split('.')[0] + '-atomic-', delete=False) as f:
|
||||
f.write(data)
|
||||
retry_on_fail(os.replace, f.name, file_path)
|
||||
finally:
|
||||
|
Loading…
x
Reference in New Issue
Block a user