diff --git a/ActiveSync/SOGoActiveSyncDispatcher.m b/ActiveSync/SOGoActiveSyncDispatcher.m index 82c1868fc..0d5287a8a 100644 --- a/ActiveSync/SOGoActiveSyncDispatcher.m +++ b/ActiveSync/SOGoActiveSyncDispatcher.m @@ -457,13 +457,12 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. NSData *d; // - // We mark the cache object as deleted + // We destroy the cache object // key = [NSString stringWithFormat: @"%@+%@", [context objectForKey: @"DeviceId"], [folderToDelete nameInContainer]]; o = [SOGoCacheGCSObject objectWithName: key inContainer: nil]; [o setTableUrl: [self folderTableURL]]; - [o reloadIfNeeded]; - [o delete]; + [o destroy]; // // We update the FolderSync's synckey @@ -697,7 +696,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. if (![imapGUIDs allKeysForObject: cKey]) { - // Delete folders cache content to avoid stale data if a new folder gets created with the same name + // Destroy folders cache content to avoid stale data if a new folder gets created with the same name key = [NSString stringWithFormat: @"%@+folder%@", [context objectForKey: @"DeviceId"], [cachedGUIDs objectForKey: cKey]]; o = [SOGoCacheGCSObject objectWithName: key inContainer: nil]; [o setObjectType: ActiveSyncFolderCacheObject]; @@ -711,8 +710,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. command_count++; } - [[o properties] removeAllObjects]; - [o save]; + [o destroy]; } } diff --git a/NEWS b/NEWS index 05c96d586..742d6e268 100644 --- a/NEWS +++ b/NEWS @@ -16,6 +16,7 @@ Bug fixes - we now correctly add the "METHOD:REPLY" when sending out ITIP messages from DAV clients - fixed refresh of message headers when forwarding a message (#2818) - we now correctly escape all charset= in tags, not only in the + - we now destroy cache objects of vanished folders 2.2.6 (2014-07-02) ------------------ diff --git a/SoObjects/SOGo/SOGoCacheGCSObject.m b/SoObjects/SOGo/SOGoCacheGCSObject.m index 03269d9d7..0b3ba25e8 100644 --- a/SoObjects/SOGo/SOGoCacheGCSObject.m +++ b/SoObjects/SOGo/SOGoCacheGCSObject.m @@ -456,6 +456,40 @@ static EOAttribute *textColumn = nil; return nil; } +- (NSException *) destroy +{ + NSString *tableName, *pathValue, *sql; + EOAdaptorChannel *channel; + GCSChannelManager *cm; + NSException *result; + EOAdaptor *adaptor; + + cm = [GCSChannelManager defaultChannelManager]; + channel = [cm acquireOpenChannelForURL: [self tableUrl]]; + tableName = [self tableName]; + + adaptor = [[channel adaptorContext] adaptor]; + pathValue = [adaptor formatValue: [self path] + forAttribute: textColumn]; + result = nil; + + sql = [NSString stringWithFormat: + (@"DELETE FROM %@" + @" WHERE c_path = %@"), + tableName, + pathValue]; + + result = [channel evaluateExpressionX: sql]; + + if (result) + [self errorWithFormat: @"could not delete record %@" + @" in %@: %@", pathValue, tableName, result]; + + [cm releaseChannel: channel]; + + return result; +} + - (void) save { NSString *sql; diff --git a/SoObjects/SOGo/SOGoCacheObject.h b/SoObjects/SOGo/SOGoCacheObject.h index 0d0a78492..d8b01c468 100644 --- a/SoObjects/SOGo/SOGoCacheObject.h +++ b/SoObjects/SOGo/SOGoCacheObject.h @@ -42,6 +42,8 @@ - (NSCalendarDate *) creationDate; - (NSCalendarDate *) lastModified; +- (NSException *) destroy; + @end #endif /* SOGOCACHEOBJECT_H */