CalDAV: Explicitly exclude items

Excluding items without mimetype "text/calendar" becomes necessary when
listing items, because iCloud would re-send us the URL we issued the
REPORT request on, a collection, with a mimetype of
"httpd/unix-directory".

    debug: REPORT https://p28-caldav.icloud.com/8010146223/calendars/home/
    debug: {'Depth': 'infinity', 'Content-Type': 'application/xml; charset=UTF-8', 'User-Agent': 'vdirsyncer '}
    debug: <?xml version="1.0" encoding="utf-8" ?>
    debug:             <C:calendar-query xmlns:D="DAV:"
    debug:                 xmlns:C="urn:ietf:params:xml:ns:caldav">
    debug:                 <D:prop>
    debug:                     <D:getetag/>
    debug:                 </D:prop>
    debug:                 <C:filter>
    debug:
    debug:                 <C:comp-filter name="VCALENDAR">
    debug:                     <C:comp-filter name="VTODO">
    debug:
    debug:                     </C:comp-filter>
    debug:                 </C:comp-filter>
    debug:
    debug:                 </C:filter>
    debug:             </C:calendar-query>
    debug: Sending request...
    debug: 207
    debug: {'content-encoding': 'gzip', 'transfer-encoding': 'chunked', 'server': 'iCloudCalendarServer 14F4 1', 'last-modified': 'Tue, 02 Sep 2014 13:59:11 GMT', 'dav': '1, access-control, calendar-access, calend ar-schedule, calendar-auto-schedule, calendar-managed-attachments, calendarserver-sharing, calendarserve r-subscribed, calendarserver-home-sync', 'x-transaction-id': '7f311996-32b4-11e4-a6db-78e3b5058dc0', 'da te': 'Tue, 02 Sep 2014 15:19:13 GMT', 'x-responding-server': 'mr21p28ic-hpaf05163701 18 a63660a6f7d1a25b 5a7ed66dab0da843', 'content-type': 'text/xml'}
    debug: <?xml version='1.0' encoding='UTF-8'?><multistatus xmlns='DAV:'>
    debug:
    debug:   <response>
    debug:     <href>/8010146223/calendars/home/</href>
    debug:     <propstat>
    debug:       <prop>
    debug:          <getetag>"FT=-@RU=301785db-0889-442c-ab5d-03144258969a@S=30"</getetag>
    debug:         <getcontenttype>httpd/unix-directory</getcontenttype>
    debug:       </prop>
    debug:       <status>HTTP/1.1 200 OK</status>
    debug:     </propstat>
    debug:   </response>
    debug:
    debug:   <response>
    debug:     <href>/8010146223/calendars/home/412580F4-7A0A-480D-BA99-73260B921E5D.ics</href>
    debug:     <propstat>
    debug:       <prop>
    debug:         <getetag>"C=30@U=301785db-0889-442c-ab5d-03144258969a"</getetag>
    debug:         <getcontenttype>text/calendar</getcontenttype>
    ...
This commit is contained in:
Markus Unterwaditzer 2014-09-02 17:16:20 +02:00
parent 4426fbc1d3
commit add9f640b4

View file

@ -410,10 +410,20 @@ class DavStorage(Storage):
)
root = etree.XML(response.content)
for element in root.iter('{DAV:}response'):
etag = element.find('{DAV:}propstat').find(
'{DAV:}prop').find('{DAV:}getetag').text
propstat = element.find('{DAV:}propstat')
prop = propstat.find('{DAV:}prop')
contenttype = prop.find('{DAV:}getcontenttype').text
etag = prop.find('{DAV:}getetag').text
href = self._normalize_href(element.find('{DAV:}href').text)
yield href, etag
if self.item_mimetype not in contenttype:
dav_logger.debug(
'Skipping item with href {!r} '
'because content type {!r} != {!r}.'
.format(href, contenttype, self.item_mimetype))
else:
yield href, etag
class CaldavStorage(DavStorage):
@ -520,6 +530,7 @@ class CaldavStorage(DavStorage):
<C:calendar-query xmlns:D="DAV:"
xmlns:C="urn:ietf:params:xml:ns:caldav">
<D:prop>
<D:getcontenttype/>
<D:getetag/>
</D:prop>
<C:filter>