diff --git a/radicale/ical.py b/radicale/ical.py index 5889976..9030b3e 100644 --- a/radicale/ical.py +++ b/radicale/ical.py @@ -230,8 +230,9 @@ class Collection(object): result.append(cls(path, principal)) try: for filename in next(os.walk(abs_path))[2]: - if cls.is_collection(os.path.join(abs_path, filename)): - result.append(cls(os.path.join(path, filename))) + collection = cls(os.path.join(path, filename)) + if collection.exists: + result.append(collection) except StopIteration: # Directory does not exist yet pass @@ -245,11 +246,12 @@ class Collection(object): result.extend(collection.components) return result - def is_collection(self, path): - """Return ``True`` if there is a collection file under ``path``.""" + @property + def exists(self): + """Return ``True`` if there is a collection file exists.""" beginning_string = 'BEGIN:%s' % self.tag - with open(path) as stream: - beginning_string = stream.read(len(beginning_string)) + with open(self.path) as stream: + return beginning_string == stream.read(len(beginning_string)) @property def items(self): diff --git a/radicale/xmlutils.py b/radicale/xmlutils.py index 7139e12..81e1a1d 100644 --- a/radicale/xmlutils.py +++ b/radicale/xmlutils.py @@ -242,6 +242,7 @@ def _propfind_response(path, item, props, user): elif tag in ( _tag("D", "principal-collection-set"), _tag("C", "calendar-user-address-set"), + _tag("CR", "addressbook-home-set"), _tag("C", "calendar-home-set")): tag = ET.Element(_tag("D", "href")) tag.text = path