diff --git a/radicale/__init__.py b/radicale/__init__.py index 73996b2c..8abf1307 100644 --- a/radicale/__init__.py +++ b/radicale/__init__.py @@ -441,7 +441,13 @@ class Application(object): # Case 3: Item and no Etag precondition: Force modifying item xmlutils.put(environ["PATH_INFO"], content, collection) status = client.CREATED - headers["ETag"] = collection.get_item(item_name).etag + # Try to return the etag in the header + # If the added item does't have the same name as the one given by + # the client, then there's no obvious way to generate an etag, we + # can safely ignore it. + new_item = collection.get_item(item_name) + if new_item: + headers["ETag"] = new_item.etag else: # PUT rejected in all other cases status = client.PRECONDITION_FAILED