Skip to content

Commit

Permalink
ikhal: Fix deleting instances of recurring events
Browse files Browse the repository at this point in the history
Before, after marking instances of recurring events as deleted, ikhal
would crash when trying to delete those events when exiting.

fixes pimutils#793
  • Loading branch information
geier committed Jul 8, 2022
1 parent dc2188f commit 6a93007
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
7 changes: 7 additions & 0 deletions khal/khalendar/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,13 @@ def get(self, href: str, calendar: str) -> str:
item, etag = self.sql_ex(sql_s, (href, calendar))[0]
return item

def get_with_etag(self, href: str, calendar: str) -> Tuple[str, str]:
"""returns the ical string and its etag matching href and calendar"""
assert calendar is not None
sql_s = 'SELECT item, etag FROM events WHERE href = ? AND calendar = ?;'
item, etag = self.sql_ex(sql_s, (href, calendar))[0]
return item, etag

def search(self, search_string: str) \
-> Iterable[Tuple[str, str, dt.date, dt.date, str, str, str]]:
"""search for events matching `search_string`"""
Expand Down
5 changes: 2 additions & 3 deletions khal/khalendar/khalendar.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,9 +224,8 @@ def delete(self, href: str, etag: Optional[str], calendar: str):

def get_event(self, href: str, calendar: str) -> Event:
"""get an event by its href from the datatbase"""
return self._construct_event(
self._backend.get(href, calendar), href=href, calendar=calendar,
)
event_str, etag = self._backend.get_with_etag(href, calendar)
return self._construct_event(event_str, etag=etag, href=href, calendar=calendar)

def _construct_event(self,
item: str,
Expand Down

0 comments on commit 6a93007

Please sign in to comment.