mirror of
https://github.com/samsonjs/vdirsyncer.git
synced 2026-04-27 14:57:41 +00:00
parent
ce1c255152
commit
2170a4fce2
4 changed files with 5 additions and 4 deletions
|
|
@ -42,7 +42,8 @@ class NotFoundError(PreconditionFailed):
|
||||||
|
|
||||||
|
|
||||||
class AlreadyExistingError(PreconditionFailed):
|
class AlreadyExistingError(PreconditionFailed):
|
||||||
'''Item already exists'''
|
'''Item already exists.'''
|
||||||
|
existing_href = None
|
||||||
|
|
||||||
|
|
||||||
class WrongEtagError(PreconditionFailed):
|
class WrongEtagError(PreconditionFailed):
|
||||||
|
|
|
||||||
|
|
@ -138,7 +138,7 @@ class FilesystemStorage(Storage):
|
||||||
return fpath, get_etag_from_fileobject(f)
|
return fpath, get_etag_from_fileobject(f)
|
||||||
except OSError as e:
|
except OSError as e:
|
||||||
if e.errno == errno.EEXIST:
|
if e.errno == errno.EEXIST:
|
||||||
raise exceptions.AlreadyExistingError(item)
|
raise exceptions.AlreadyExistingError(existing_href=href)
|
||||||
else:
|
else:
|
||||||
raise
|
raise
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ class MemoryStorage(Storage):
|
||||||
def upload(self, item):
|
def upload(self, item):
|
||||||
href = self._get_href(item)
|
href = self._get_href(item)
|
||||||
if href in self.items:
|
if href in self.items:
|
||||||
raise exceptions.AlreadyExistingError(item)
|
raise exceptions.AlreadyExistingError(existing_href=href)
|
||||||
etag = _random_string()
|
etag = _random_string()
|
||||||
self.items[href] = (etag, item)
|
self.items[href] = (etag, item)
|
||||||
return href, etag
|
return href, etag
|
||||||
|
|
|
||||||
|
|
@ -134,7 +134,7 @@ class SingleFileStorage(Storage):
|
||||||
def upload(self, item):
|
def upload(self, item):
|
||||||
href = item.ident
|
href = item.ident
|
||||||
if href in self._items:
|
if href in self._items:
|
||||||
raise exceptions.AlreadyExistingError(href)
|
raise exceptions.AlreadyExistingError(existing_href=href)
|
||||||
|
|
||||||
self._items[href] = item, item.hash
|
self._items[href] = item, item.hash
|
||||||
return href, item.hash
|
return href, item.hash
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue