From eb5587f4cac35bab0c7392664b40065941887b72 Mon Sep 17 00:00:00 2001 From: Markus Unterwaditzer Date: Mon, 15 Dec 2014 19:16:33 +0100 Subject: [PATCH] Fix racecondition in status creation --- vdirsyncer/cli.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/vdirsyncer/cli.py b/vdirsyncer/cli.py index 2847317..3d93fb5 100644 --- a/vdirsyncer/cli.py +++ b/vdirsyncer/cli.py @@ -7,6 +7,7 @@ :license: MIT, see LICENSE for more details. ''' +import errno import functools import json import os @@ -133,8 +134,12 @@ def save_status(path, status_name, status): 'automatically, but this choice is left to the ' 'user. If you think this is an error, please file ' 'a bug at {}'.format(base_path, PROJECT_HOME)) - if not os.path.exists(base_path): + + try: os.makedirs(base_path, 0o750) + except OSError as e: + if e.errno != errno.EEXIST: + raise with safe_write(full_path, 'w+') as f: for k, v in status.items():