Skip to content

Commit

Permalink
Retry PUT 409 errors - delete and re-create event
Browse files Browse the repository at this point in the history
Attempt to address #963

I would appreciate a code review here - there might be a more elegant way to address this problem, but it works for my (very limited) use case.
  • Loading branch information
telotortium committed Jan 18, 2022
1 parent 68c5968 commit 3c14c30
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion vdirsyncer/storage/dav.py
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,16 @@ async def _put(self, href, item, etag):
async def update(self, href, item, etag):
if etag is None:
raise ValueError("etag must be given and must not be None.")
href, etag = await self._put(self._normalize_href(href), item, etag)
try:
href, etag = await self._put(self._normalize_href(href), item, etag)
except aiohttp.ClientResponseError as e:
if e.status == 409:
dav_logger.debug("Conflict, will delete old event and recreate it.")
await self.delete(self._normalize_href(href), None)
dav_logger.debug("Now trying again")
href, etag = await self._put(self._normalize_href(href), item, None)
else:
raise e
return etag

async def upload(self, item: Item):
Expand Down

0 comments on commit 3c14c30

Please sign in to comment.