From b5434c74410bd368421154394f57bfe25a4db949 Mon Sep 17 00:00:00 2001 From: midas Date: Sat, 12 Jul 2025 08:16:30 +0000 Subject: [PATCH] library/calendar_sync.py aktualisiert --- library/calendar_sync.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/library/calendar_sync.py b/library/calendar_sync.py index 561cafd..80b3d5e 100644 --- a/library/calendar_sync.py +++ b/library/calendar_sync.py @@ -47,14 +47,20 @@ def sync_ics_to_caldav(module): module.params['verify_ssl'] ) - existing_events = { - str(event.icalendar_component.uid): event - for event in target_cal.events() - } + # Bestehende Events aus dem Zielkalender einlesen und UIDs extrahieren + existing_events = {} + for event in target_cal.events(): + try: + vobj = vobject.readOne(event.data) + uid = str(vobj.vevent.uid) + existing_events[uid] = event + except Exception as e: + raise Exception(f"Fehler beim Parsen eines bestehenden Events: {str(e)}") changed = False results = {'added': [], 'updated': [], 'removed': []} + # Neue ICS-Events einfügen oder updaten for vevent in ics_events: uid = str(vevent.uid) ical_data = vevent.serialize() @@ -69,6 +75,7 @@ def sync_ics_to_caldav(module): results['updated'].append(uid) changed = True + # Nicht mehr vorhandene Events löschen, wenn gewünscht if module.params['purge']: current_uids = {str(e.uid) for e in ics_events} for uid in set(existing_events.keys()) - current_uids: