From c5342d36d5b8f29b732ad0d788174d07108f4076 Mon Sep 17 00:00:00 2001 From: Unrud Date: Thu, 25 Aug 2016 06:28:20 +0200 Subject: [PATCH] Remove BaseCollection.update I don't think that this can be used for optimizations. It's useless in the filesystem backend, SQL has REPLACE and I doubt that there is much use in any other storage mechanism. --- radicale/__init__.py | 5 +---- radicale/storage.py | 25 +------------------------ 2 files changed, 2 insertions(+), 28 deletions(-) diff --git a/radicale/__init__.py b/radicale/__init__.py index 0bc8d1d..ec784c5 100644 --- a/radicale/__init__.py +++ b/radicale/__init__.py @@ -600,10 +600,7 @@ class Application: if tag: parent_item.set_meta({"tag": tag}) 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} return client.CREATED, headers, None diff --git a/radicale/storage.py b/radicale/storage.py index 102bfc1..b259cb4 100644 --- a/radicale/storage.py +++ b/radicale/storage.py @@ -318,7 +318,7 @@ class BaseCollection: return self.get(href) is not None def upload(self, href, vobject_item): - """Upload a new item.""" + """Upload a new or replace an existing item.""" raise NotImplementedError def upload_all(self, vobject_items): @@ -334,16 +334,6 @@ class BaseCollection: for href, vobject_item in vobject_items.items() ] - 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): """Delete an item. @@ -644,19 +634,6 @@ class Collection(BaseCollection): if not is_safe_filesystem_path_component(href): raise UnsafePathError(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) with self._atomic_write(path, newline="") as fd: fd.write(item.serialize())