Merge branch 'remupdate' of https://github.com/Unrud/Radicale into Unrud-remupdate
This commit is contained in:
commit
9e78454da2
@ -612,9 +612,6 @@ class Application:
|
|||||||
if tag:
|
if tag:
|
||||||
parent_item.set_meta({"tag": tag})
|
parent_item.set_meta({"tag": tag})
|
||||||
href = posixpath.basename(path.strip("/"))
|
href = posixpath.basename(path.strip("/"))
|
||||||
if item:
|
|
||||||
new_item = parent_item.update(href, items[0])
|
|
||||||
else:
|
|
||||||
new_item = parent_item.upload(href, items[0])
|
new_item = parent_item.upload(href, items[0])
|
||||||
headers = {"ETag": new_item.etag}
|
headers = {"ETag": new_item.etag}
|
||||||
return client.CREATED, headers, None
|
return client.CREATED, headers, None
|
||||||
|
@ -320,19 +320,9 @@ class BaseCollection:
|
|||||||
return self.get(href) is not None
|
return self.get(href) is not None
|
||||||
|
|
||||||
def upload(self, href, vobject_item):
|
def upload(self, href, vobject_item):
|
||||||
"""Upload a new item."""
|
"""Upload a new or replace an existing item."""
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
def update(self, href, vobject_item):
|
|
||||||
"""Update an item.
|
|
||||||
|
|
||||||
Functionally similar to ``delete`` plus ``upload``, but might bring
|
|
||||||
performance benefits on some storages when used cleverly.
|
|
||||||
|
|
||||||
"""
|
|
||||||
self.delete(href)
|
|
||||||
self.upload(href, vobject_item)
|
|
||||||
|
|
||||||
def delete(self, href=None):
|
def delete(self, href=None):
|
||||||
"""Delete an item.
|
"""Delete an item.
|
||||||
|
|
||||||
@ -654,19 +644,6 @@ class Collection(BaseCollection):
|
|||||||
if not is_safe_filesystem_path_component(href):
|
if not is_safe_filesystem_path_component(href):
|
||||||
raise UnsafePathError(href)
|
raise UnsafePathError(href)
|
||||||
path = path_to_filesystem(self._filesystem_path, href)
|
path = path_to_filesystem(self._filesystem_path, href)
|
||||||
if os.path.exists(path):
|
|
||||||
raise ComponentExistsError(href)
|
|
||||||
item = Item(self, vobject_item, href)
|
|
||||||
with self._atomic_write(path, newline="") as fd:
|
|
||||||
fd.write(item.serialize())
|
|
||||||
return item
|
|
||||||
|
|
||||||
def update(self, href, vobject_item):
|
|
||||||
if not is_safe_filesystem_path_component(href):
|
|
||||||
raise UnsafePathError(href)
|
|
||||||
path = path_to_filesystem(self._filesystem_path, href)
|
|
||||||
if not os.path.isfile(path):
|
|
||||||
raise ComponentNotFoundError(href)
|
|
||||||
item = Item(self, vobject_item, href)
|
item = Item(self, vobject_item, href)
|
||||||
with self._atomic_write(path, newline="") as fd:
|
with self._atomic_write(path, newline="") as fd:
|
||||||
fd.write(item.serialize())
|
fd.write(item.serialize())
|
||||||
|
Loading…
Reference in New Issue
Block a user