From f6ace2b6ecd9919437110c09b598d46932bb4e00 Mon Sep 17 00:00:00 2001 From: Guillaume Ayoub Date: Wed, 21 Mar 2012 11:26:06 +0100 Subject: [PATCH] Fix a bug with DELETE requests when deleted item is not found --- radicale/__init__.py | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/radicale/__init__.py b/radicale/__init__.py index e2c201d..2b5a8a0 100644 --- a/radicale/__init__.py +++ b/radicale/__init__.py @@ -285,17 +285,16 @@ class Application(object): item = collection.get_item( xmlutils.name_from_path(environ["PATH_INFO"], collection)) - # Evolution bug workaround - etag = environ.get("HTTP_IF_MATCH", item.etag).replace("\\", "") - if item and etag == item.etag: - # No ETag precondition or precondition verified, delete item - answer = xmlutils.delete(environ["PATH_INFO"], collection) - status = client.NO_CONTENT - else: - # No item or ETag precondition not verified, do not delete item - answer = None - status = client.PRECONDITION_FAILED - return status, {}, answer + if item: + # Evolution bug workaround + etag = environ.get("HTTP_IF_MATCH", item.etag).replace("\\", "") + if etag == item.etag: + # No ETag precondition or precondition verified, delete item + answer = xmlutils.delete(environ["PATH_INFO"], collection) + return client.NO_CONTENT, {}, answer + + # No item or ETag precondition not verified, do not delete item + return client.PRECONDITION_FAILED, {}, None def get(self, environ, collections, content, user): """Manage GET request.