calcurse-caldav: always request href from server
Apparently, while some CalDAV servers return href values as is in their response, some might return them URL-quoted (which, if I am not mistaken, was the reason for e943b06). Assuming either behaviour when pushing local objects will lead to discrepancy with events dictionary retrieved from the server and thus bugs, hence we always want to use whatever form of href the server returns. Addresses GitHub issues #337 and #356. Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
This commit is contained in:
parent
5398f3a24e
commit
cb6b3340f8
@ -9,7 +9,6 @@ import re
|
||||
import subprocess
|
||||
import sys
|
||||
import textwrap
|
||||
import urllib.parse
|
||||
import xml.etree.ElementTree as etree
|
||||
|
||||
import httplib2
|
||||
@ -420,18 +419,21 @@ def push_object(conn, objhash):
|
||||
|
||||
if not headers:
|
||||
return None
|
||||
|
||||
etag = None
|
||||
headerdict = dict(headers)
|
||||
if 'etag' in headerdict:
|
||||
etag = headerdict['etag']
|
||||
while not etag:
|
||||
etagdict = get_etags(conn, [href])
|
||||
if etagdict:
|
||||
etag = next(iter(etagdict.values()))
|
||||
etag = etag.strip('"')
|
||||
|
||||
return (urllib.parse.quote(href), etag)
|
||||
# Retrieve href from server to match server-side format. Retrieve ETag
|
||||
# unless it can be extracted from the PUT response already.
|
||||
ret_href, ret_etag = None, headerdict.get('etag')
|
||||
while not ret_etag or not ret_href:
|
||||
etagdict = get_etags(conn, [href])
|
||||
if not etagdict:
|
||||
continue
|
||||
ret_href, new_etag = next(iter(etagdict.items()))
|
||||
# Favor ETag from PUT response to avoid race condition.
|
||||
if not ret_etag:
|
||||
ret_etag = new_etag
|
||||
|
||||
return (ret_href, ret_etag.strip('"'))
|
||||
|
||||
|
||||
def push_objects(objhashes, conn, syncdb, etagdict):
|
||||
|
Loading…
x
Reference in New Issue
Block a user