From 224d0d47e8b8851104be6ba365985eedc8c79cd6 Mon Sep 17 00:00:00 2001 From: Guillaume Ayoub Date: Mon, 20 Feb 2012 17:41:36 +0100 Subject: [PATCH] Fix the collection detection --- radicale/storage/filesystem.py | 9 +++++---- radicale/xmlutils.py | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/radicale/storage/filesystem.py b/radicale/storage/filesystem.py index ec57bb2..8360e63 100644 --- a/radicale/storage/filesystem.py +++ b/radicale/storage/filesystem.py @@ -23,6 +23,7 @@ Filesystem storage backend. import codecs import os +import posixpath import json import time from contextlib import contextmanager @@ -76,10 +77,10 @@ class Collection(ical.Collection): @classmethod def children(cls, path): - rel_path = path.replace("/", os.sep) - abs_path = os.path.join(FOLDER, rel_path) - for filename in next(os.walk(abs_path))[2]: - rel_filename = os.path.join(rel_path, filename) + abs_path = os.path.join(FOLDER, path.replace("/", os.sep)) + _, directories, files = next(os.walk(abs_path)) + for filename in directories + files: + rel_filename = posixpath.join(path, filename) if cls.is_collection(rel_filename) or cls.is_item(rel_filename): yield cls(rel_filename) diff --git a/radicale/xmlutils.py b/radicale/xmlutils.py index eace8da..41a0d7a 100644 --- a/radicale/xmlutils.py +++ b/radicale/xmlutils.py @@ -279,7 +279,7 @@ def _propfind_response(path, item, props, user): if item.is_principal: tag = ET.Element(_tag("D", "principal")) element.append(tag) - else: + if item.is_item(item.path): tag = ET.Element(_tag("C", item.resource_type)) element.append(tag) tag = ET.Element(_tag("D", "collection"))