Skip to content

Commit

Permalink
Add support for uploading whole collections
Browse files Browse the repository at this point in the history
  • Loading branch information
39aldo39 committed May 29, 2022
1 parent 16ba74a commit b8404fd
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions radicale_storage_decsync/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,14 +212,22 @@ def create_collection(self, href, items=None, props=None):
return super().create_collection(href, items, props)
username, collection = attributes

if items is not None:
raise ValueError("Uploading a whole collection is currently not supported with the DecSync plugin")

tag = props.get("tag")
if tag == "VADDRESSBOOK":
sync_type = "contacts"
elif tag == "VCALENDAR":
components = props.get("C:supported-calendar-component-set", "VEVENT").split(",")
components = props.get("C:supported-calendar-component-set")
if components is None:
if collection.startswith("calendars-"):
components = "VEVENT"
elif collection.startswith("tasks-"):
components = "VTODO"
elif collection.startswith("memos-"):
components = "VJOURNAL"
else:
# Default
components = "VEVENT"
components = components.split(",")
component = components[0]
if component == "VEVENT":
sync_type = "calendars"
Expand All @@ -241,4 +249,9 @@ def create_collection(self, href, items=None, props=None):
path = "/%s/%s/" % (username, collection)
else:
path = "/%s/%s-%s/" % (username, sync_type, collection)
return super().create_collection(path, items, props)
col = super().create_collection(path, None, props)
if items is not None:
for item in items:
href = col.get_href(item.uid)
col.upload(href, item)
return col

0 comments on commit b8404fd

Please sign in to comment.