From 5bd80d8d1385d27fe1b9efd9664bd658fd87ca97 Mon Sep 17 00:00:00 2001 From: Guillaume Ayoub Date: Thu, 14 Jul 2016 01:39:57 +0200 Subject: [PATCH] Don't crash when getting unknown collections Fix #422. --- radicale/__init__.py | 5 ++++- radicale/storage.py | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/radicale/__init__.py b/radicale/__init__.py index f413fa9e..fa0e0e6e 100644 --- a/radicale/__init__.py +++ b/radicale/__init__.py @@ -409,7 +409,10 @@ class Application: else: # Get whole collection answer = collection.serialize() - etag = collection.etag + if answer is None: + return client.NOT_FOUND, {}, None + else: + etag = collection.etag if answer: headers = { diff --git a/radicale/storage.py b/radicale/storage.py index 5e142534..37bf565e 100644 --- a/radicale/storage.py +++ b/radicale/storage.py @@ -543,6 +543,8 @@ class Collection(BaseCollection): return time.strftime("%a, %d %b %Y %H:%M:%S GMT", time.gmtime(last)) def serialize(self): + if not os.path.exists(self._filesystem_path): + return None items = [] for href in os.listdir(self._filesystem_path): path = os.path.join(self._filesystem_path, href)