diff --git a/vdirsyncer/storage/singlefile.py b/vdirsyncer/storage/singlefile.py index f08d4c2..723c553 100644 --- a/vdirsyncer/storage/singlefile.py +++ b/vdirsyncer/storage/singlefile.py @@ -78,7 +78,7 @@ class SingleFileStorage(Storage): def __init__(self, path, encoding='utf-8', **kwargs): super(SingleFileStorage, self).__init__(**kwargs) - path = expand_path(path) + path = os.path.abspath(expand_path(path)) collection = kwargs.get('collection') if collection is not None: @@ -97,7 +97,8 @@ class SingleFileStorage(Storage): raise ValueError('collection is not a valid argument for {}' .format(cls.__name__)) - checkfile(kwargs['path'], create=True) + path = os.path.abspath(expand_path(kwargs['path'])) + checkfile(path, create=True) return kwargs def list(self): diff --git a/vdirsyncer/utils/__init__.py b/vdirsyncer/utils/__init__.py index b67e5f3..269c50a 100644 --- a/vdirsyncer/utils/__init__.py +++ b/vdirsyncer/utils/__init__.py @@ -301,7 +301,10 @@ def checkfile(path, create=False): if not os.path.isfile(path): if os.path.exists(path): raise IOError('{} is not a file.'.format(path)) - if not create: + if create: + with open(path, 'wb') as f: + pass + else: raise exceptions.CollectionNotFound('File {} does not exist.' .format(path))