mirror of
git://github.com/kovidgoyal/calibre.git
synced 2025-12-06 16:26:32 +01:00
Use a prefix for the atomic write tempfile
This commit is contained in:
parent
3e97ae74d6
commit
65219abb3d
1 changed files with 1 additions and 1 deletions
|
|
@ -375,7 +375,7 @@ def commit_data(file_path, data):
|
||||||
bdir = os.path.dirname(file_path)
|
bdir = os.path.dirname(file_path)
|
||||||
os.makedirs(bdir, exist_ok=True, mode=CONFIG_DIR_MODE)
|
os.makedirs(bdir, exist_ok=True, mode=CONFIG_DIR_MODE)
|
||||||
try:
|
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)
|
f.write(data)
|
||||||
retry_on_fail(os.replace, f.name, file_path)
|
retry_on_fail(os.replace, f.name, file_path)
|
||||||
finally:
|
finally:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue