mirror of
https://github.com/samsonjs/vdirsyncer.git
synced 2026-04-27 14:57:41 +00:00
Fix various collection creation bugs
This commit is contained in:
parent
334ade7e6b
commit
7d727ecef3
2 changed files with 7 additions and 3 deletions
|
|
@ -78,7 +78,7 @@ class SingleFileStorage(Storage):
|
||||||
|
|
||||||
def __init__(self, path, encoding='utf-8', **kwargs):
|
def __init__(self, path, encoding='utf-8', **kwargs):
|
||||||
super(SingleFileStorage, self).__init__(**kwargs)
|
super(SingleFileStorage, self).__init__(**kwargs)
|
||||||
path = expand_path(path)
|
path = os.path.abspath(expand_path(path))
|
||||||
|
|
||||||
collection = kwargs.get('collection')
|
collection = kwargs.get('collection')
|
||||||
if collection is not None:
|
if collection is not None:
|
||||||
|
|
@ -97,7 +97,8 @@ class SingleFileStorage(Storage):
|
||||||
raise ValueError('collection is not a valid argument for {}'
|
raise ValueError('collection is not a valid argument for {}'
|
||||||
.format(cls.__name__))
|
.format(cls.__name__))
|
||||||
|
|
||||||
checkfile(kwargs['path'], create=True)
|
path = os.path.abspath(expand_path(kwargs['path']))
|
||||||
|
checkfile(path, create=True)
|
||||||
return kwargs
|
return kwargs
|
||||||
|
|
||||||
def list(self):
|
def list(self):
|
||||||
|
|
|
||||||
|
|
@ -301,7 +301,10 @@ def checkfile(path, create=False):
|
||||||
if not os.path.isfile(path):
|
if not os.path.isfile(path):
|
||||||
if os.path.exists(path):
|
if os.path.exists(path):
|
||||||
raise IOError('{} is not a file.'.format(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.'
|
raise exceptions.CollectionNotFound('File {} does not exist.'
|
||||||
.format(path))
|
.format(path))
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue