From 07cbc4f79f1ac39689391d64e27c59f2860a271a Mon Sep 17 00:00:00 2001 From: mrvladus Date: Thu, 23 May 2024 19:58:46 +0300 Subject: [PATCH] fix #300 --- errands/lib/sync/providers/caldav.py | 30 +++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/errands/lib/sync/providers/caldav.py b/errands/lib/sync/providers/caldav.py index 1b986fe9..bb232e9a 100644 --- a/errands/lib/sync/providers/caldav.py +++ b/errands/lib/sync/providers/caldav.py @@ -235,16 +235,16 @@ def __sync_lists(self): self.__update_local_list(cal, list) else: self.__update_remote_list(cal, list) - if list.uid not in remote_lists_uids and list.synced and not list.deleted: - self.__delete_local_list(list) - elif list.uid in remote_lists_uids and list.deleted and list.synced: - self.__delete_remote_list(list) - elif ( + if ( list.uid not in remote_lists_uids and not list.synced and not list.deleted ): self.__create_remote_list(list) + elif list.uid not in remote_lists_uids and list.synced and not list.deleted: + self.__delete_local_list(list) + elif list.uid in remote_lists_uids and list.deleted and list.synced: + self.__delete_remote_list(list) def __add_local_lists(self) -> None: user_lists_uids = [lst.uid for lst in UserData.get_lists_as_dicts()] @@ -399,19 +399,31 @@ def __update_remote_task(self, calendar: Calendar, task: TaskData) -> None: if task.due_date: todo.icalendar_component["due"] = task.due_date else: - del todo.icalendar_component["due"] + try: + del todo.icalendar_component["due"] + except BaseException: + pass if task.start_date: todo.icalendar_component["dtstart"] = task.start_date else: - del todo.icalendar_component["dtstart"] + try: + del todo.icalendar_component["dtstart"] + except BaseException: + pass if task.created_at: todo.icalendar_component["dtstamp"] = task.created_at else: - del todo.icalendar_component["dtstamp"] + try: + del todo.icalendar_component["dtstamp"] + except BaseException: + pass if task.changed_at: todo.icalendar_component["last-modified"] = task.changed_at else: - del todo.icalendar_component["last-modified"] + try: + del todo.icalendar_component["last-modified"] + except BaseException: + pass todo.icalendar_component["summary"] = task.text todo.icalendar_component["percent-complete"] = int(task.percent_complete) todo.icalendar_component["description"] = task.notes