chiark / gitweb /
Don't store instances of recurring events in the cache
authorMatthew Vernon <mv3@sanger.ac.uk>
Fri, 19 Oct 2018 16:39:10 +0000 (17:39 +0100)
committerMatthew Vernon <mv3@sanger.ac.uk>
Fri, 19 Oct 2018 16:39:10 +0000 (17:39 +0100)
...as they don't appear in the usual listing, which means we end up
considering them as deleted events.

gooswapper.py

index f54038cc1e2efa526a7ac31ff134738e4c781456..1187be17231d84808ad9756410d75f21d3d46c29 100644 (file)
@@ -190,7 +190,7 @@ def modify_recurring(ex_acct,gcal_acct,gcal_tz,
             instance = get_gcal_recur_instance(gcal_acct,master.gcal_link,
                                                mod.original_start,gcal_id)
             if instance is None: #give up after first failure
-                return events
+                return
             mod_event = get_ex_event_by_itemid(ex_acct.calendar,mod.item_id)
             gevent = build_gcal_event_from_ex(mod_event,gcal_tz)
             gevent = gcal_acct.events().update(calendarId=gcal_id,
@@ -199,24 +199,18 @@ def modify_recurring(ex_acct,gcal_acct,gcal_tz,
                                                sendUpdates="none").execute()
             mod_event.gcal_link = gevent.get("id")
             mod_event.save(update_fields=["gcal_link"])
-            if mod_event.item_id in events:
-                events[mod_event.item_id] = events[mod_event.item_id]._replace(changekey=mod_event.changekey,gcal_link=mod_event.gcal_link)
-            else:
-                events[mod_event.item_id] = CachedExEvent(mod_event.changekey,
-                                                      mod_event.gcal_link)
     if master.deleted_occurrences is not None:
         for d in master.deleted_occurrences:
             instance = get_gcal_recur_instance(gcal_acct,master.gcal_link,
                                                d.start,gcal_id)
             if instance is None: #give up after any failure
-                return events
+                return
             if instance["status"] != "cancelled":
                 instance["status"]="cancelled"
                 gcal_acct.events().update(calendarId=gcal_id,
                                           eventId=instance.get('id'),
                                           body=instance,
                                           sendUpdates="none").execute()
-    return events
 
 def build_gcal_event_from_ex(event,gcal_tz):
     gevent={}
@@ -258,8 +252,8 @@ def add_ex_to_gcal(ex_acct,
         events[event.item_id] = events[event.item_id]._replace(changekey=event.changekey,gcal_link=event.gcal_link)
         if event.type=="RecurringMaster" and (event.deleted_occurrences or \
                                               event.modified_occurrences):
-            events = modify_recurring(ex_acct,gcal_acct,gcal_tz,
-                                      events,event,gcal_id)
+            modify_recurring(ex_acct,gcal_acct,gcal_tz,
+                             events,event,gcal_id)
         
 def del_ex_to_gcal(ex_acct, gcal_acct, events, deleted, gcal_id="primary"):
     for ev_id in deleted: