Parcourir la source

Don't crash when getting unknown collections

Fix #422.
Guillaume Ayoub il y a 9 ans
Parent
commit
5bd80d8d13
2 fichiers modifiés avec 6 ajouts et 1 suppressions
  1. 4 1
      radicale/__init__.py
  2. 2 0
      radicale/storage.py

+ 4 - 1
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 = {

+ 2 - 0
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)