From 03cbcee5cd9ecd4966c0f5ddd36facd358f5d6a9 Mon Sep 17 00:00:00 2001 From: Unrud Date: Mon, 1 Aug 2016 20:46:57 +0200 Subject: [PATCH] / is not a principal --- radicale/storage.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/radicale/storage.py b/radicale/storage.py index 446d7bb..a878306 100644 --- a/radicale/storage.py +++ b/radicale/storage.py @@ -355,25 +355,27 @@ class Collection(BaseCollection): # path should already be sanitized sane_path = sanitize_path(path).strip("/") attributes = sane_path.split("/") - if not attributes: - return + if not attributes[0]: + attributes.pop() # Try to guess if the path leads to a collection or an item folder = os.path.expanduser( cls.configuration.get("storage", "filesystem_folder")) if not os.path.isdir(path_to_filesystem(folder, sane_path)): # path is not a collection - if os.path.isfile(path_to_filesystem(folder, sane_path)): + if attributes and os.path.isfile(path_to_filesystem(folder, + sane_path)): # path is an item attributes.pop() - elif os.path.isdir(path_to_filesystem(folder, *attributes[:-1])): + elif attributes and os.path.isdir(path_to_filesystem( + folder, *attributes[:-1])): # path parent is a collection attributes.pop() # TODO: else: return? path = "/".join(attributes) - principal = len(attributes) <= 1 + principal = len(attributes) == 1 collection = cls(path, principal) yield collection if depth != "0":