oc: Implement move a DB subfolder to root

DB folders are Notes and Fallback (Journal, InfoPath Form and Deleted Items).

By moving the DB path and update the indexing DB.
pull/69/head
Enrique J. Hernández Blasco 2015-02-05 23:49:59 +01:00
parent dc8012e3d3
commit 142deeb5f0
1 changed files with 21 additions and 8 deletions

View File

@ -140,7 +140,7 @@ static NSString *MAPIStoreRightFolderContact = @"RightsFolderContact";
pathComponent = nil;
if (isMove && [targetFolder isKindOfClass: MAPIStoreDBFolderK])
if (isMove && ([targetFolder isKindOfClass: MAPIStoreDBFolderK] || !targetFolder))
{
path = [sogoObject path];
slashRange = [path rangeOfString: @"/" options: NSBackwardsSearch];
@ -149,15 +149,28 @@ static NSString *MAPIStoreRightFolderContact = @"RightsFolderContact";
format: @"db folder path must start with a '/'"];
else
pathComponent = [path substringFromIndex: slashRange.location + 1];
targetPath = [[targetFolder sogoObject] path];
newPath = [NSString stringWithFormat: @"%@/%@",
targetPath, pathComponent];
[dbFolder changePathTo: newPath
intoNewContainer: [targetFolder dbFolder]];
if (targetFolder)
{
targetPath = [[targetFolder sogoObject] path];
newPath = [NSString stringWithFormat: @"%@/%@",
targetPath, pathComponent];
[dbFolder changePathTo: newPath
intoNewContainer: [targetFolder dbFolder]];
}
else
[dbFolder changePathTo: [NSString stringWithFormat: @"/fallback/%@", pathComponent]
intoNewContainer: nil];
mapping = [self mapping];
newURL = [NSString stringWithFormat: @"%@%@/",
[targetFolder url], pathComponent];
if (targetFolder)
newURL = [NSString stringWithFormat: @"%@%@/",
[targetFolder url], pathComponent];
else
newURL = [NSString stringWithFormat: @"sogo://%@@fallback/%@/",
[[self userContext] username], pathComponent];
[mapping updateID: [self objectId]
withURL: newURL];