mirror of
https://github.com/samsonjs/vdirsyncer.git
synced 2026-04-27 14:57:41 +00:00
Fix racecondition in status creation
This commit is contained in:
parent
e40ba55bd3
commit
eb5587f4ca
1 changed files with 6 additions and 1 deletions
|
|
@ -7,6 +7,7 @@
|
||||||
:license: MIT, see LICENSE for more details.
|
:license: MIT, see LICENSE for more details.
|
||||||
'''
|
'''
|
||||||
|
|
||||||
|
import errno
|
||||||
import functools
|
import functools
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
|
|
@ -133,8 +134,12 @@ def save_status(path, status_name, status):
|
||||||
'automatically, but this choice is left to the '
|
'automatically, but this choice is left to the '
|
||||||
'user. If you think this is an error, please file '
|
'user. If you think this is an error, please file '
|
||||||
'a bug at {}'.format(base_path, PROJECT_HOME))
|
'a bug at {}'.format(base_path, PROJECT_HOME))
|
||||||
if not os.path.exists(base_path):
|
|
||||||
|
try:
|
||||||
os.makedirs(base_path, 0o750)
|
os.makedirs(base_path, 0o750)
|
||||||
|
except OSError as e:
|
||||||
|
if e.errno != errno.EEXIST:
|
||||||
|
raise
|
||||||
|
|
||||||
with safe_write(full_path, 'w+') as f:
|
with safe_write(full_path, 'w+') as f:
|
||||||
for k, v in status.items():
|
for k, v in status.items():
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue