Skip to content

Commit

Permalink
Don't cache recurring instances into googleExceptions.
Browse files Browse the repository at this point in the history
  • Loading branch information
phw198 committed Jan 2, 2025
1 parent 4585bcc commit a4c5776
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/OutlookGoogleCalendarSync/Google/GoogleCalendar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ public List<Event> GetCalendarEntriesInRange(System.DateTime from, System.DateTi
}
}

Recurrence.SeparateGoogleExceptions(result);
Recurrence.Instance.SeparateGoogleExceptions(result);

log.Fine("Filtered down to " + result.Count);
return result;
Expand Down
30 changes: 14 additions & 16 deletions src/OutlookGoogleCalendarSync/Recurrence.cs
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ public void SeparateGoogleExceptions(List<Event> allEvents) {
}

/// <summary>
/// Get occurrence that originally started on a particular date
/// Search cached exceptions for occurrence that originally started on a particular date
/// </summary>
/// <param name="recurringEventId">The recurring series to search within</param>
/// <param name="originalInstanceDate">The date to search for</param>
Expand Down Expand Up @@ -462,29 +462,27 @@ private Event getGoogleInstance(Microsoft.Office.Interop.Outlook.Exception oExcp
}
}
if (dirtyCache) {
log.Debug("Google exception cache not being used. Retrieving all recurring instances afresh...");
log.Debug("Google exception cache not being used. Retrieving all recurring exceptions afresh...");
//Remove dirty items
googleExceptions.RemoveAll(ev => ev.RecurringEventId == gRecurringEventID);
} else {
foreach (Event gExcp in googleExceptions) {
if (gExcp.RecurringEventId == gRecurringEventID) {
if (((oIsDeleted == DeletionState.NotDeleted || (oIsDeleted == DeletionState.Deleted && !oExcp.Deleted)) /* Weirdness when exception is cancelled by organiser but not yet deleted/accepted by recipient */
&& oExcp.OriginalDate == gExcp.OriginalStartTime.SafeDateTime()
) ||
(oIsDeleted == DeletionState.Deleted &&
oExcp.OriginalDate == gExcp.OriginalStartTime.SafeDateTime().Date
)) {
return gExcp;
}
Google.Calendar.Instance.GetCalendarEntriesInRange(gRecurringEventID);
}
foreach (Event gExcp in googleExceptions) {
if (gExcp.RecurringEventId == gRecurringEventID) {
if (((oIsDeleted == DeletionState.NotDeleted || (oIsDeleted == DeletionState.Deleted && !oExcp.Deleted)) /* Weirdness when exception is cancelled by organiser but not yet deleted/accepted by recipient */
&& oExcp.OriginalDate == gExcp.OriginalStartTime.SafeDateTime()
) ||
(oIsDeleted == DeletionState.Deleted &&
oExcp.OriginalDate == gExcp.OriginalStartTime.SafeDateTime().Date
)) {
return gExcp;
}
}
log.Debug("Google exception event is not cached. Retrieving all recurring instances...");
}
log.Debug("Google exception event is not cached. Retrieving all recurring instances...");
List<Event> gInstances = Ogcs.Google.Calendar.Instance.GetCalendarEntriesInRecurrence(gRecurringEventID);
if (gInstances == null) return null;

//Add any new exceptions to local cache
googleExceptions = googleExceptions.Union(gInstances.Where(ev => !String.IsNullOrEmpty(ev.RecurringEventId))).ToList();
foreach (Event gInst in gInstances) {
if (gInst.RecurringEventId == gRecurringEventID) {
if (((oIsDeleted == DeletionState.NotDeleted || (oIsDeleted == DeletionState.Deleted && !oExcp.Deleted)) /* Weirdness when exception is cancelled by organiser but not yet deleted/accepted by recipient */
Expand Down

0 comments on commit a4c5776

Please sign in to comment.