>The assumption is correct because a sync remains resumable only if no >other profile is synced in between (should be that way, see update >below). This is because the implementation cannot hold resume states >for more than one profile (e.g. the chgl_markedforresume flag would >need to be per profile). This is of course a compromise, but I >considered that acceptable. > >Because of this, your sample scenario cannot happen as described Lukas, thanks for your explanation, I really missed something.
>My suggestion would be: > >- implement the modcount_created stuff so we have reliable information >to distinguish adds and replaces. > >- let them travel through the engine as sop_add. I have done this, please have a reivew. === diff --git a/src/sysync/binfileimplds.cpp b/src/sysync/binfileimplds.cpp index 224119e..9cca090 100755 --- a/src/sysync/binfileimplds.cpp +++ b/src/sysync/binfileimplds.cpp @@ -747,6 +747,9 @@ localstatus TBinfileImplDS::changeLogPreflight(bool &aValidChangelog) newentry.flags=0; // modified now newentry.modcount=fCurrentModCount; + // set the creation timestamp, this is used to detect a client-side + // new added item + newentry.modcount_created=fCurrentModCount; #ifndef CHANGEDETECTION_AVAILABLE // no CRC yet newentry.dataCRC=0; @@ -1374,6 +1377,10 @@ localstatus TBinfileImplDS::implGetItem( // - update the mod count such that this record will be detected again in the next non-resumed session // (fCurrentModCount marks entries changed in this session, +1 makes sure these will be detected in the NEXT session) chglogP->modcount=fCurrentModCount+1; + //also update the creation stamp for new added item + if(chglogP->modcount_created > fPreviousToRemoteModCount) { + chglogP->modcount_created=fCurrentModCount+1; + } // - mark it "modified by sync" to prevent it being sent during resume chglogP->flags |= chgl_modbysync; } @@ -1472,8 +1479,12 @@ localstatus TBinfileImplDS::implGetItem( goto error; } } - // added or changed, syncop is replace - myitemP->setSyncOp(sop_replace); + // detect wheter the item is new added or changed + if( chglogP->modcount_created > fPreviousToRemoteModCount) { + myitemP->setSyncOp(sop_add); + } else { + myitemP->setSyncOp(sop_replace); + } // make sure item has the localid which was used to retrieve it ASSIGN_LOCALID_TO_ITEM(*myitemP,chglogP->dbrecordid); } diff --git a/src/sysync/binfileimplds.h b/src/sysync/binfileimplds.h index 11b492d..d43f371 100755 --- a/src/sysync/binfileimplds.h +++ b/src/sysync/binfileimplds.h @@ -163,6 +163,8 @@ typedef struct { #endif // modification count of last modification uInt32 modcount; + //creation timestamp for the record + uInt32 modcount_created; #ifndef CHANGEDETECTION_AVAILABLE // CRC of the record's data after the last modification uInt16 dataCRC; Regards, Congwu
0001-Binfile-Changelog-really-detect-a-new-added-item.patch
Description: 0001-Binfile-Changelog-really-detect-a-new-added-item.patch
_______________________________________________ os-libsynthesis mailing list os-libsynthesis@synthesis.ch http://lists.synthesis.ch/mailman/listinfo/os-libsynthesis