diff -r d0791faffa3f -r aabe5387f5ce mtpfws/mtpfw/src/cmtpobjectstore.cpp --- a/mtpfws/mtpfw/src/cmtpobjectstore.cpp Tue Feb 02 01:11:40 2010 +0200 +++ b/mtpfws/mtpfw/src/cmtpobjectstore.cpp Fri Mar 19 09:40:39 2010 +0200 @@ -280,17 +280,23 @@ void CMTPObjectStore::CommitReservedObjectHandleL(CMTPObjectMetaData& aObject) { + TFileName suid; + suid.CopyLC(aObject.DesC(CMTPObjectMetaData::ESuid)); + TUint32 handle = HandleL(suid); + if (handle != KMTPHandleNone) + { + __FLOG(_L8("CommitReserverd leave for duplicate suid.")); + User::Leave(KErrAlreadyExists); + } + TUint32 suidHash = DefaultHash::Des16(suid); + //After the PutL called the cursor's position is not well defined. iCachedHandle = 0; iCachedSuidHash = 0; TInt64 id = iHandleAllocator->NextPOUIDL(); aObject.SetUint(CMTPObjectMetaData::EIdentifier, id); - TFileName suid; - suid.CopyLC(aObject.DesC(CMTPObjectMetaData::ESuid)); - TUint32 suidHash = DefaultHash::Des16(suid); - - TUint32 handle = aObject.Uint(CMTPObjectMetaData::EHandle); + handle = aObject.Uint(CMTPObjectMetaData::EHandle); CleanupStack::PushL(TCleanupItem(CMTPObjectStore::DBUpdateFailRecover, &iBatched)); iBatched.InsertL(); iBatched.SetColL(EObjectStoreHandleId, handle); @@ -385,6 +391,7 @@ TBool needToInsert = EFalse; TBool needUpdateOwner = EFalse; TUint dpId(aObject.Uint(CMTPObjectMetaData::EDataProviderId)); + TFileName suid; suid.CopyLC(aObject.DesC(CMTPObjectMetaData::ESuid)); TUint32 suidHash = DefaultHash::Des16(suid); @@ -392,7 +399,7 @@ TUint32 handle = KMTPHandleNone, handleInDB = KMTPHandleAll; TInt64 id = 0; // Check if the dp is enumerating - if (iSingletons.DpController().EnumerateState() != CMTPDataProviderController::EEnumerated && iCacheExist) + if (iSingletons.DpController().EnumerateState() != CMTPDataProviderController::EEnumeratedFulllyCompleted && iCacheExist) { //it is in the object enumeration phase. // if it's see if we have an object with the same SUID @@ -438,7 +445,8 @@ } else { - User::Leave(KErrAlreadyExists); + //while enumerating, we ignore the repeatedly INSERT operations. + //User::Leave(KErrAlreadyExists); } } } @@ -556,6 +564,14 @@ if (LocateByHandleL(handle)) { + //To avoid this modification will not generate duplicate SUID + TUint32 handle2 = HandleL(suid); + if (handle2 != KMTPHandleNone && handle2 != handle) + { + __FLOG(_L8("ModifyObjectL leave for duplicate suid.")); + User::Leave(KErrAlreadyExists); + } + //After the PutL called the cursor's position is not well defined. iCachedHandle = 0; iCachedSuidHash = 0; @@ -686,7 +702,7 @@ { if (LocateByHandleL(aHandle.Value())) { - if (iSingletons.DpController().EnumerateState() != CMTPDataProviderController::EEnumerated && + if (iSingletons.DpController().EnumerateState() != CMTPDataProviderController::EEnumeratedFulllyCompleted && IsMediaFormat(iBatched.ColUint16(EObjectStoreFormatCode))) { iMtpDeltaDataMgr->UpdateDeltaDataTableL(iBatched.ColInt64(EObjectStorePOUID), CMtpDeltaDataMgr::EDeleted); @@ -702,7 +718,7 @@ { if(LocateBySuidL(aSuid)) { - if (iSingletons.DpController().EnumerateState() != CMTPDataProviderController::EEnumerated && + if (iSingletons.DpController().EnumerateState() != CMTPDataProviderController::EEnumeratedFulllyCompleted && IsMediaFormat(iBatched_SuidHashID.ColUint16(EObjectStoreFormatCode))) { iMtpDeltaDataMgr->UpdateDeltaDataTableL(iBatched_SuidHashID.ColInt64(EObjectStorePOUID), CMtpDeltaDataMgr::EDeleted);