Properly destroy cache objects of vanished folders

pull/48/head
Ludovic Marcotte 2014-07-24 08:39:41 -04:00
parent 037dd67635
commit 006727a74b
4 changed files with 41 additions and 6 deletions

View File

@ -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];
}
}

1
NEWS
View File

@ -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 <meta> tags, not only in the <head>
- we now destroy cache objects of vanished folders
2.2.6 (2014-07-02)
------------------

View File

@ -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;

View File

@ -42,6 +42,8 @@
- (NSCalendarDate *) creationDate;
- (NSCalendarDate *) lastModified;
- (NSException *) destroy;
@end
#endif /* SOGOCACHEOBJECT_H */