mirror of
https://github.com/samsonjs/vdirsyncer.git
synced 2026-03-28 09:25:50 +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):
|
||||
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):
|
||||
|
|
|
|||
|
|
@ -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))
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue