diff options
-rwxr-xr-x | contrib/caldav/calcurse-caldav.py | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/contrib/caldav/calcurse-caldav.py b/contrib/caldav/calcurse-caldav.py index 5c028bf..f40c12b 100755 --- a/contrib/caldav/calcurse-caldav.py +++ b/contrib/caldav/calcurse-caldav.py @@ -135,6 +135,27 @@ def remote_query(conn, cmd, path, additional_headers, body): return (headers, body) +def get_hrefs(conn): + body = ('<?xml version="1.0" encoding="utf-8" ?>' + '<D:propfind xmlns:D="DAV:"><D:prop><D:getetag/></D:prop></D:propfind>' ) + headers, body = remote_query(conn, "PROPFIND", path, {}, body) + + if not headers: + return {} + + root = etree.fromstring(body) + + hreflist = [] + for node in root.findall(".//D:response", namespaces=nsmap): + hrefnode = node.find("./D:href", namespaces=nsmap) + if hrefnode is None: + die_atnode('Missing href.', node) + href = hrefnode.text + + hreflist.append(href) + + return hreflist + def get_etags(conn, hrefs=[]): if len(hrefs) > 0: @@ -525,9 +546,10 @@ try: ' --init=keep-local Remove all remote objects\n' + ' --init=two-way Copy local items to the server and vice versa') + hreflist = get_hrefs(conn) # Query the server and compute a lookup table that maps each path to its # current ETag. - etagdict = get_etags(conn) + etagdict = get_etags(conn, hreflist) # Compute object diffs. missing = set() |