From 1c5baea83d3f42d00440ddd20a9b28d2a909714c Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Mon, 7 Mar 2011 18:58:14 +0000 Subject: [PATCH] Monotone-Parent: cca78e92405cd0f44d20538ad0b0e699160785fd Monotone-Revision: 482fb2f36da6ff311c3c19eb3752da985fdae5cd Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2011-03-07T18:58:14 Monotone-Branch: ca.inverse.sogo --- ChangeLog | 13 +++++++++++-- SoObjects/SOGo/SOGoCache.h | 2 ++ SoObjects/SOGo/SOGoCache.m | 13 +++++++++++++ SoObjects/SOGo/SOGoContentObject.m | 12 +++++++++++- SoObjects/SOGo/SOGoGCSFolder.h | 2 ++ SoObjects/SOGo/SOGoGCSFolder.m | 5 +++++ 6 files changed, 44 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7de279d05..2d714f007 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,11 +1,20 @@ +2011-03-07 Wolfgang Sourdeau + + * SoObjects/SOGo/SOGoCache.m + (-unregisterObjectWithName:inContainer:): same as below. + + * SoObjects/SOGo/SOGoGCSFolder.m (-removeChildRecordWithName:): + new method to ensure a child records is removed from the cache + when modified or deleted. + 2011-03-04 Ludovic Marcotte * SoObjects/Appointments/SOGoAppointmentFolder.h/m: -importCalendar: we now also import the timezone definition when present - * SoObjects/SOGo/SQLSource.m + * SoObjects/SOGo/SQLSource.m We now consider the domain belonging to the SQLSource instance - + 2011-02-25 Wolfgang Sourdeau * OpenChange/MAPIStoreMailContext.[hm]: renamed from diff --git a/SoObjects/SOGo/SOGoCache.h b/SoObjects/SOGo/SOGoCache.h index ccbeb3be9..f3d8a7b75 100644 --- a/SoObjects/SOGo/SOGoCache.h +++ b/SoObjects/SOGo/SOGoCache.h @@ -57,6 +57,8 @@ - (void) registerObject: (id) object withName: (NSString *) name inContainer: (SOGoObject *) container; +- (void) unregisterObjectWithName: (NSString *) name + inContainer: (SOGoObject *) container; - (id) objectNamed: (NSString *) name inContainer: (SOGoObject *) container; diff --git a/SoObjects/SOGo/SOGoCache.m b/SoObjects/SOGo/SOGoCache.m index 7a2d6c259..0041eb0d4 100644 --- a/SoObjects/SOGo/SOGoCache.m +++ b/SoObjects/SOGo/SOGoCache.m @@ -209,6 +209,19 @@ static memcached_st *handle = NULL; } } +- (void) unregisterObjectWithName: (NSString *) name + inContainer: (SOGoObject *) container +{ + NSString *fullPath; + + if (name) + { + fullPath = [self _pathFromObject: container + withName: name]; + [cache removeObjectForKey: fullPath]; + } +} + - (id) objectNamed: (NSString *) name inContainer: (SOGoObject *) container { diff --git a/SoObjects/SOGo/SOGoContentObject.m b/SoObjects/SOGo/SOGoContentObject.m index 44a459227..6ebb8968f 100644 --- a/SoObjects/SOGo/SOGoContentObject.m +++ b/SoObjects/SOGo/SOGoContentObject.m @@ -33,6 +33,7 @@ #import #import "NSCalendarDate+SOGo.h" +#import "SOGoCache.h" #import "SOGoGCSFolder.h" #import "SOGoUser.h" #import "SOGoPermissions.h" @@ -199,7 +200,11 @@ } else [self errorWithFormat:@"Did not find folder of content object."]; - + + [container removeChildRecordWithName: nameInContainer]; + [[SOGoCache sharedCache] unregisterObjectWithName: nameInContainer + inContainer: container]; + return ex; } @@ -249,6 +254,11 @@ [self errorWithFormat:@"delete failed: %@", ex]; return ex; } + + [container removeChildRecordWithName: nameInContainer]; + [[SOGoCache sharedCache] unregisterObjectWithName: nameInContainer + inContainer: container]; + return nil; } diff --git a/SoObjects/SOGo/SOGoGCSFolder.h b/SoObjects/SOGo/SOGoGCSFolder.h index 73c578a7b..8a85ee59f 100644 --- a/SoObjects/SOGo/SOGoGCSFolder.h +++ b/SoObjects/SOGo/SOGoGCSFolder.h @@ -81,6 +81,8 @@ - (Class) objectClassForComponentName: (NSString *) componentName; - (Class) objectClassForContent: (NSString *) content; +- (void) removeChildRecordWithName: (NSString *) childName; + - (id) createChildComponentWithRecord: (NSDictionary *) record; - (id) createChildComponentWithName: (NSString *) newName andContent: (NSString *) newContent; diff --git a/SoObjects/SOGo/SOGoGCSFolder.m b/SoObjects/SOGo/SOGoGCSFolder.m index 2079525ea..81e696237 100644 --- a/SoObjects/SOGo/SOGoGCSFolder.m +++ b/SoObjects/SOGo/SOGoGCSFolder.m @@ -712,6 +712,11 @@ static NSArray *childRecordFields = nil; return (record != nil); } +- (void) removeChildRecordWithName: (NSString *) childName +{ + [childRecords removeObjectForKey: childName]; +} + - (Class) objectClassForComponentName: (NSString *) componentName { [self subclassResponsibility: _cmd];