diff --git a/radicale/__init__.py b/radicale/__init__.py index ae53c89..f70e58d 100644 --- a/radicale/__init__.py +++ b/radicale/__init__.py @@ -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)) diff --git a/radicale/xmlutils.py b/radicale/xmlutils.py index 68603b9..ff91f82 100644 --- a/radicale/xmlutils.py +++ b/radicale/xmlutils.py @@ -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"))