calcurse-caldav: handle objects with status code 404

Display a warning if any of the events reported by the server cannot be
found instead of bailing out.

Addresses GitHub issue #137 and #245.

Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
This commit is contained in:
Si Yong Kim 2019-09-23 23:01:11 -07:00 committed by Lukas Fleischer
parent 35eaa4a737
commit b293b1829d

View File

@ -442,6 +442,16 @@ def pull_objects(hrefs_missing, hrefs_modified, conn, syncdb, etagdict):
die_atnode('Missing href.', node) die_atnode('Missing href.', node)
href = hrefnode.text href = hrefnode.text
statusnode = node.find("./D:status", namespaces=nsmap)
if statusnode is not None:
status = re.match(r'HTTP.*(\d\d\d)', statusnode.text)
if status is None:
die_atnode('Could not parse status.', node)
statuscode = status.group(1)
if statuscode == '404':
print('Skipping missing item: {}'.format(href))
continue
etagnode = node.find("./D:propstat/D:prop/D:getetag", namespaces=nsmap) etagnode = node.find("./D:propstat/D:prop/D:getetag", namespaces=nsmap)
if etagnode is None: if etagnode is None:
die_atnode('Missing ETag.', node) die_atnode('Missing ETag.', node)