Skip to content

Commit

Permalink
ikhal: fix deleting of multiple instances
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
geier committed Jun 23, 2023
1 parent e92d747 commit a416301
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion khal/ui/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1109,12 +1109,18 @@ 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.
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']
Expand Down

0 comments on commit a416301

Please sign in to comment.