Skip to content

Commit

Permalink
DAV: Don't violate Storage API
Browse files Browse the repository at this point in the history
The implementation of #476 is problematic as it returns None.
`vdirsyncer.sync` has internal assertions that this is a string, which
is why we get a crash.

Discovered in #467
  • Loading branch information
untitaker committed Aug 19, 2016
1 parent 214ec10 commit e456afb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
4 changes: 2 additions & 2 deletions tests/test_sync.py
Expand Up @@ -422,8 +422,8 @@ def get(href):
if null_etag_on_upload:
_old_upload = s.upload
_old_update = s.update
s.upload = lambda item: (_old_upload(item)[0], None)
s.update = lambda h, i, e: _old_update(h, i, e) and None
s.upload = lambda item: (_old_upload(item)[0], 'NULL')
s.update = lambda h, i, e: _old_update(h, i, e) and 'NULL'

return s

Expand Down
7 changes: 3 additions & 4 deletions vdirsyncer/storage/dav.py
Expand Up @@ -479,10 +479,9 @@ def _put(self, href, item, etag):
#
# -- https://tools.ietf.org/html/rfc7231#section-4.3.4
#
# In such cases we return None as etag. The next synchronization will
# then detect an etag change (None != some string) and will download
# the new item.
etag = response.headers.get('etag', None)
# In such cases we return a constant etag. The next synchronization
# will then detect an etag change and will download the new item.
etag = response.headers.get('etag', 'NULL')
href = self._normalize_href(response.url)
return href, etag

Expand Down

0 comments on commit e456afb

Please sign in to comment.