Fix various collection creation bugs

This commit is contained in:
Markus Unterwaditzer 2015-02-02 19:19:22 +01:00
parent 334ade7e6b
commit 7d727ecef3
2 changed files with 7 additions and 3 deletions

View file

@ -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):

View file

@ -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))