From 142deeb5f0ed97cbc78f7641a7c5141d30aefd70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Enrique=20J=2E=20Hern=C3=A1ndez=20Blasco?= Date: Thu, 5 Feb 2015 23:49:59 +0100 Subject: [PATCH] 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. --- OpenChange/MAPIStoreDBFolder.m | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/OpenChange/MAPIStoreDBFolder.m b/OpenChange/MAPIStoreDBFolder.m index 798af041b..4dd7fbfd9 100644 --- a/OpenChange/MAPIStoreDBFolder.m +++ b/OpenChange/MAPIStoreDBFolder.m @@ -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];