see ChangeLog

Monotone-Parent: e614ca6146bb5052469a2b393909509aa081acc0
Monotone-Revision: fb42e2a1670666605ac484d419b64d92c83f004d

Monotone-Author: wsourdeau@inverse.ca
Monotone-Date: 2010-10-28T15:47:29
Monotone-Branch: ca.inverse.sogo
This commit is contained in:
Wolfgang Sourdeau
2010-10-28 15:47:29 +00:00
parent e5dbe26e96
commit 6cd140cc5d
2 changed files with 55 additions and 5 deletions

View File

@@ -1,3 +1,11 @@
2010-10-28 Wolfgang Sourdeau <wsourdeau@inverse.ca>
* SoObjects/Appointments/SOGoAppointmentFolders.m
(-_migrateWebCalendarsSettings): fixed a bug where the active
user's login name would be used as comparison prefix, leading to a
corrupted and very long calendar key. Added code to migrate those
previously corrupted keys to their proper form.
2010-10-27 Wolfgang Sourdeau <wsourdeau@inverse.ca>
* UI/Contacts/UIxContactView.m (-categories): new accessor for

View File

@@ -414,6 +414,44 @@ static SoSecurityManager *sm = nil;
return componentSet;
}
/* This method fixes an issue that occurred previously in
_migrateWebCalendarsSettings, where the active user, rather than the
owner's login would be taken to compose the expected key prefix, leading to
a corrupted calendar key with an endless chain of
[user]:/Calendar/[user]:/Calendar/[user].... occurrences. */
- (NSString *) _fixedWebCalendarKey: (NSString *) oldKey
{
NSString *newKey;
NSRange lastOccurrence, fullOccurrence;
lastOccurrence = [oldKey rangeOfString: @":Calendar/"
options: NSBackwardsSearch];
if ([oldKey rangeOfString: @":Calendar/"].location != lastOccurrence.location)
{
fullOccurrence
= [oldKey rangeOfString:
[NSString stringWithFormat: @"%@:Calendar/",
owner]
options: NSBackwardsSearch];
if (fullOccurrence.location != NSNotFound)
{
newKey = [oldKey substringFromIndex: fullOccurrence.location];
[self logWithFormat: @"fixed erroneous calendar key: '%@' -> '%@'",
oldKey, newKey];
}
else
{
[self errorWithFormat: @"calendar key cannot be fixed: '%@'",
oldKey];
newKey = nil;
}
}
else
newKey = nil;
return newKey;
}
- (void) _migrateWebCalendarsSettings
{
SOGoUserSettings *us;
@@ -426,20 +464,24 @@ static SoSecurityManager *sm = nil;
hasChanged = NO;
us = [[context activeUser] userSettings];
prefix = [NSString stringWithFormat: @"%@:Calendar/",
[self ownerInContext: context]];
us = [[SOGoUser userWithLogin: owner] userSettings];
module = [us objectForKey: @"Calendar"];
webCalendars = [module objectForKey: @"WebCalendars"];
keys = [webCalendars allKeys];
max = [keys count];
prefix = [NSString stringWithFormat: @"%@:Calendar/",
[self ownerInContext: context]];
for (count = 0; count < max; count++)
{
oldKey = [keys objectAtIndex: count];
if (![oldKey hasPrefix: prefix])
if ([oldKey hasPrefix: prefix])
newKey = [self _fixedWebCalendarKey: oldKey];
else
newKey = [prefix stringByAppendingString: oldKey];
if (newKey)
{
newKey = [prefix stringByAppendingString: oldKey];
[webCalendars setObject: [webCalendars objectForKey: oldKey]
forKey: newKey];
[webCalendars removeObjectForKey: oldKey];