From fe5be01f9cb3f23bba1c058aedef422d50f331de Mon Sep 17 00:00:00 2001 From: Christian Geier Date: Sat, 17 Jun 2023 17:54:07 +0200 Subject: [PATCH] ikhal: fix deleting of multiple instances When deleting multiple instances of the same recurring event, ikhal would crash because of mismatching etags. This would happen, because we delete one instance after the next, each time updating the etag. As we check for matching etags when deleting (the one in the database and the one stored in ikhal), this would crash ikhal. Matching the etag makes sense, as we might overwrite freshly synced data otherwise. For now, the server wins. --- khal/ui/__init__.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/khal/ui/__init__.py b/khal/ui/__init__.py index 3a9f43791..da8e8de98 100644 --- a/khal/ui/__init__.py +++ b/khal/ui/__init__.py @@ -1109,12 +1109,20 @@ def toggle_delete_instance(self, uid): def cleanup(self, data): """delete all events marked for deletion""" + # If we delete several recuids from the same vevent, the etag will + # change after each deletion. As we check for matching etags before + # deleting, deleting any subsequent recuids will fail. + # We therefore keep track of the etags of the events we already + # deleted. + updated_etags = {} for part in self._deleted[ALL]: account, href, etag = part.split('\n', 2) self.collection.delete(href, etag, account) for part, rec_id in self._deleted[INSTANCES]: account, href, etag = part.split('\n', 2) - self.collection.delete_instance(href, etag, account, rec_id) + etag = updated_etags.get(href) or etag + event = self.collection.delete_instance(href, etag, account, rec_id) + updated_etags[event.href] = event.etag def keypress(self, size, key): binds = self._conf['keybindings']