mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-10-19 18:18:12 +00:00
oc-folder: Make deleted items synched when shared
By keeping mid on moving messages by soft deleting and only if srcMid is different from targetMid. This makes restore/shared deleted items work. It also requires to do the following to work smoothly: * Do not add soft-deleted messages in ensureIDsForChildKeys * Return soft-deleted messages on getDeletedFMIDs * Do not register a new mid if the URL is matched with soft deleted messages
This commit is contained in:
1 parent
35ca313c37
commit
b67e1deda5
3 files changed
+36
-11
No files matched your search
@@ -679,6 +679,7 @@ Class NSExceptionK, MAPIStoreFAIMessageK, MAPIStoreMessageTableK, MAPIStoreFAIMe
|
|||||||
//TALLOC_CTX *memCtx;
|
//TALLOC_CTX *memCtx;
|
||||||
struct SRow aRow;
|
struct SRow aRow;
|
||||||
struct SPropValue property;
|
struct SPropValue property;
|
||||||
|
uint8_t deleteFlags;
|
||||||
|
|
||||||
[self logWithFormat: @"-moveCopyMessageWithMID: 0x%.16llx .. withMID: 0x%.16llx .. wantCopy: %d", srcMid, targetMid, wantCopy];
|
[self logWithFormat: @"-moveCopyMessageWithMID: 0x%.16llx .. withMID: 0x%.16llx .. wantCopy: %d", srcMid, targetMid, wantCopy];
|
||||||
|
|
||||||
@@ -709,7 +710,9 @@ Class NSExceptionK, MAPIStoreFAIMessageK, MAPIStoreMessageTableK, MAPIStoreFAIMe
|
|||||||
}
|
}
|
||||||
[destMsg save: memCtx];
|
[destMsg save: memCtx];
|
||||||
if (!wantCopy)
|
if (!wantCopy)
|
||||||
rc = [sourceFolder deleteMessageWithMID: srcMid andFlags: 0];
|
/* We want to keep mid for restoring/shared data to work if mids are different. */
|
||||||
|
deleteFlags = (srcMid == targetMid) ? MAPISTORE_PERMANENT_DELETE : MAPISTORE_SOFT_DELETE;
|
||||||
|
rc = [sourceFolder deleteMessageWithMID: srcMid andFlags: deleteFlags];
|
||||||
|
|
||||||
end:
|
end:
|
||||||
//talloc_free (memCtx);
|
//talloc_free (memCtx);
|
||||||
@@ -949,6 +952,7 @@ Class NSExceptionK, MAPIStoreFAIMessageK, MAPIStoreMessageTableK, MAPIStoreFAIMe
|
|||||||
NSString *baseURL, *URL, *key;
|
NSString *baseURL, *URL, *key;
|
||||||
NSArray *newIDs;
|
NSArray *newIDs;
|
||||||
uint64_t idNbr;
|
uint64_t idNbr;
|
||||||
|
bool softDeleted;
|
||||||
|
|
||||||
baseURL = [self url];
|
baseURL = [self url];
|
||||||
|
|
||||||
@@ -959,8 +963,8 @@ Class NSExceptionK, MAPIStoreFAIMessageK, MAPIStoreMessageTableK, MAPIStoreFAIMe
|
|||||||
{
|
{
|
||||||
key = [keys objectAtIndex: count];
|
key = [keys objectAtIndex: count];
|
||||||
URL = [NSString stringWithFormat: @"%@%@", baseURL, key];
|
URL = [NSString stringWithFormat: @"%@%@", baseURL, key];
|
||||||
idNbr = [mapping idFromURL: URL];
|
idNbr = [mapping idFromURL: URL isSoftDeleted: &softDeleted];
|
||||||
if (idNbr == NSNotFound)
|
if (idNbr == NSNotFound && !softDeleted)
|
||||||
[missingURLs addObject: URL];
|
[missingURLs addObject: URL];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1091,6 +1095,7 @@ Class NSExceptionK, MAPIStoreFAIMessageK, MAPIStoreMessageTableK, MAPIStoreFAIMe
|
|||||||
MAPIStoreMapping *mapping;
|
MAPIStoreMapping *mapping;
|
||||||
struct UI8Array_r *fmids;
|
struct UI8Array_r *fmids;
|
||||||
uint64_t fmid;
|
uint64_t fmid;
|
||||||
|
bool softDeleted;
|
||||||
|
|
||||||
keys = [self getDeletedKeysFromChangeNumber: changeNum andCN: &cnNbr
|
keys = [self getDeletedKeysFromChangeNumber: changeNum andCN: &cnNbr
|
||||||
inTableType: tableType];
|
inTableType: tableType];
|
||||||
@@ -1117,10 +1122,10 @@ Class NSExceptionK, MAPIStoreFAIMessageK, MAPIStoreMessageTableK, MAPIStoreFAIMe
|
|||||||
{
|
{
|
||||||
url = [NSString stringWithFormat: format,
|
url = [NSString stringWithFormat: format,
|
||||||
baseURL, [keys objectAtIndex: count]];
|
baseURL, [keys objectAtIndex: count]];
|
||||||
fmid = [mapping idFromURL: url];
|
fmid = [mapping idFromURL: url isSoftDeleted: &softDeleted];
|
||||||
if (fmid != NSNotFound) /* if no fmid is returned, then the object
|
if (fmid != NSNotFound) /* if no fmid is returned, then the object
|
||||||
"never existed" in the OpenChange
|
"never existed" in the OpenChange
|
||||||
databases */
|
databases. Soft-deleted messages are returned back */
|
||||||
{
|
{
|
||||||
fmids->lpui8[fmids->cValues] = fmid;
|
fmids->lpui8[fmids->cValues] = fmid;
|
||||||
fmids->cValues++;
|
fmids->cValues++;
|
||||||
|
|||||||
@@ -49,6 +49,8 @@
|
|||||||
- (NSString *) urlFromID: (uint64_t) idKey;
|
- (NSString *) urlFromID: (uint64_t) idKey;
|
||||||
|
|
||||||
- (uint64_t) idFromURL: (NSString *) url;
|
- (uint64_t) idFromURL: (NSString *) url;
|
||||||
|
- (uint64_t) idFromURL: (NSString *) url
|
||||||
|
isSoftDeleted: (bool *) softDeleted;
|
||||||
- (BOOL) registerURL: (NSString *) urlString
|
- (BOOL) registerURL: (NSString *) urlString
|
||||||
withID: (uint64_t) idNbr;
|
withID: (uint64_t) idNbr;
|
||||||
- (void) registerURLs: (NSArray *) urlString
|
- (void) registerURLs: (NSArray *) urlString
|
||||||
|
|||||||
@@ -160,6 +160,21 @@ MAPIStoreMappingKeyFromId (uint64_t idNbr)
|
|||||||
return NSNotFound;
|
return NSNotFound;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (uint64_t) idFromURL: (NSString *) url
|
||||||
|
isSoftDeleted: (bool *) softDeleted
|
||||||
|
{
|
||||||
|
enum mapistore_error ret;
|
||||||
|
uint64_t idNbr;
|
||||||
|
|
||||||
|
ret = indexing->get_fmid(indexing, [username UTF8String], [url UTF8String],
|
||||||
|
false, &idNbr, softDeleted);
|
||||||
|
|
||||||
|
if (ret != MAPISTORE_SUCCESS)
|
||||||
|
return NSNotFound;
|
||||||
|
|
||||||
|
return idNbr;
|
||||||
|
}
|
||||||
|
|
||||||
- (void) _updateFolderWithURL: (NSString *) oldURL
|
- (void) _updateFolderWithURL: (NSString *) oldURL
|
||||||
withURL: (NSString *) urlString
|
withURL: (NSString *) urlString
|
||||||
{
|
{
|
||||||
@@ -217,7 +232,7 @@ MAPIStoreMappingKeyFromId (uint64_t idNbr)
|
|||||||
{
|
{
|
||||||
NSString *oldURL;
|
NSString *oldURL;
|
||||||
uint64_t oldIdNbr;
|
uint64_t oldIdNbr;
|
||||||
bool rc;
|
bool rc, softDeleted;
|
||||||
|
|
||||||
oldURL = [self urlFromID: idNbr];
|
oldURL = [self urlFromID: idNbr];
|
||||||
if (oldURL != NULL)
|
if (oldURL != NULL)
|
||||||
@@ -228,13 +243,16 @@ MAPIStoreMappingKeyFromId (uint64_t idNbr)
|
|||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
oldIdNbr = [self idFromURL: urlString];
|
oldIdNbr = [self idFromURL: urlString isSoftDeleted: &softDeleted];
|
||||||
if (oldIdNbr != NSNotFound)
|
if (oldIdNbr != NSNotFound)
|
||||||
{
|
{
|
||||||
[self errorWithFormat:
|
if (softDeleted)
|
||||||
@"attempt to double register an entry with idNbr ('%@', %lld,"
|
[self logWithFormat: @"Attempt to register a soft-deleted %@", urlString];
|
||||||
@" 0x%.16"PRIx64", oldid=0x%.16"PRIx64")",
|
else
|
||||||
urlString, idNbr, idNbr, oldIdNbr];
|
[self errorWithFormat:
|
||||||
|
@"attempt to double register an entry with idNbr ('%@', %lld,"
|
||||||
|
@" 0x%.16"PRIx64", oldid=0x%.16"PRIx64")",
|
||||||
|
urlString, idNbr, idNbr, oldIdNbr];
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
Reference in new issue
Block a user