Allow creation of empty collection via PUT

This commit is contained in:
Unrud 2016-05-29 01:18:29 +02:00
parent 28e643dec1
commit 4861b79878

View File

@ -547,13 +547,18 @@ class Application:
# Case 2: Item and ETag precondition verified: Modify item
# Case 3: Item and no Etag precondition: Force modifying item
items = list(vobject.readComponents(content or ""))
if items:
if item:
# PUT is modifying an existing item
if items:
new_item = collection.update(item_name, items[0])
else:
new_item = None
elif item_name:
# PUT is adding a new item
if items:
new_item = collection.upload(item_name, items[0])
else:
new_item = None
else:
# PUT is replacing the whole collection
collection.delete()