XML error message for invalid sync-token
This commit is contained in:
parent
13381fb829
commit
3753364fc8
@ -842,6 +842,4 @@ class Application:
|
||||
headers = {"Content-Type": "text/xml; charset=%s" % self.encoding}
|
||||
status, xml_answer = xmlutils.report(
|
||||
base_prefix, path, xml_content, collection)
|
||||
if status == client.PRECONDITION_FAILED:
|
||||
return PRECONDITION_FAILED
|
||||
return (status, headers, self._write_xml_content(xml_answer))
|
||||
|
@ -127,6 +127,13 @@ def _href(base_prefix, href):
|
||||
return quote("%s%s" % (base_prefix, href))
|
||||
|
||||
|
||||
def _webdav_error(namespace, name):
|
||||
"""Generate XML error message."""
|
||||
root = ET.Element(_tag("D", "error"))
|
||||
root.append(ET.Element(_tag(namespace, name)))
|
||||
return root
|
||||
|
||||
|
||||
def _date_to_datetime(date_):
|
||||
"""Transform a date to a UTC datetime.
|
||||
|
||||
@ -1041,7 +1048,8 @@ def report(base_prefix, path, xml_request, collection):
|
||||
# Invalid sync token
|
||||
collection.logger.warning("Client provided invalid sync token %r: "
|
||||
"%s", old_sync_token, e, exc_info=True)
|
||||
return client.PRECONDITION_FAILED, None
|
||||
return (client.PRECONDITION_FAILED,
|
||||
_webdav_error("D", "valid-sync-token"))
|
||||
hreferences = ("/" + posixpath.join(collection.path, n) for n in names)
|
||||
# Append current sync token to response
|
||||
sync_token_element = ET.Element(_tag("D", "sync-token"))
|
||||
|
Loading…
Reference in New Issue
Block a user