Create directory automatically

This commit is contained in:
Markus Unterwaditzer 2017-02-18 18:32:52 +01:00
parent 7f38102936
commit cc56a05b7c
2 changed files with 3 additions and 2 deletions

View file

@ -187,7 +187,7 @@ Service to hardcode those into opensource software
The ``token_file`` parameter should be a filepath where vdirsyncer can later
store authentication-related data. You do not need to create the file itself
(or write anything to it), only the folder around it.
or write anything to it.
You can select which calendars to sync on `CalDav settings page
<https://calendar.google.com/calendar/syncselect>`_.

View file

@ -12,7 +12,7 @@ from click_threading import get_ui_worker
from . import base, dav
from .. import exceptions
from ..utils import expand_path, open_graphical_browser
from ..utils import checkdir, expand_path, open_graphical_browser
logger = logging.getLogger(__name__)
@ -58,6 +58,7 @@ class GoogleSession(dav.DAVSession):
)
def _save_token(token):
checkdir(os.path.dirname(token_file), create=True)
with atomic_write(token_file, mode='w', overwrite=True) as f:
json.dump(token, f)