--- a/mtpfws/mtpfw/src/cmtpobjectstore.cpp Fri Jun 25 16:54:01 2010 +0800
+++ b/mtpfws/mtpfw/src/cmtpobjectstore.cpp Fri Jul 09 17:58:21 2010 +0800
@@ -442,6 +442,12 @@
TBool needUpdateOwner = EFalse;
TUint dpId(aObject.Uint(CMTPObjectMetaData::EDataProviderId));
+ if ((aObject.DesC(CMTPObjectMetaData::ESuid)).Length() > KMaxFileName)
+ {
+ // The length of object uid should not excceeds KMaxFileName
+ User::Leave( KErrBadName );
+ }
+
TFileName suid;
suid.CopyLC(aObject.DesC(CMTPObjectMetaData::ESuid));
TUint32 suidHash = DefaultHash::Des16(suid);
@@ -478,7 +484,8 @@
aObject.SetUint(CMTPObjectMetaData::EHandle, handle);
id = iEnumeratingCacheObjList[found]->iPOUID;
aObject.SetUint(CMTPObjectMetaData::EIdentifier, id);
- if(iEnumeratingCacheObjList[found]->iFormatcode != aObject.Uint(CMTPObjectMetaData::EFormatCode))
+ if(iEnumeratingCacheObjList[found]->iFormatcode != aObject.Uint(CMTPObjectMetaData::EFormatCode) ||
+ iEnumeratingCacheObjList[found]->iObjParentId != aObject.Uint(CMTPObjectMetaData::EParentHandle))
{//have different owner
needUpdateOwner = ETrue;
}
@@ -523,6 +530,7 @@
needToInsert = ETrue;
__FLOG_VA((_L8("InsertObjectL After enmueration, needUpdateOwner %d needToInsert %d"), needUpdateOwner, needToInsert));
}
+
if (needToInsert)//needToInsert and needUpdateOwner can't be true at same time
{
TUint32 parentHandle(aObject.Uint(CMTPObjectMetaData::EParentHandle));
@@ -562,6 +570,7 @@
iBatched.SetColL(EObjectStoreModes, aObject.Uint(CMTPObjectMetaData::EModes));
iBatched.SetColL(EObjectStoreNonConsumable, aObject.Uint(CMTPObjectMetaData::ENonConsumable));
iBatched.SetColL(EObjectStoreName, aObject.DesC(CMTPObjectMetaData::EName));
+ iBatched.SetColL(EObjectStoreParentHandle, aObject.Uint(CMTPObjectMetaData::EParentHandle));
iBatched.PutL();
CleanupStack::Pop(&iBatched);
IncTranOpsNumL();
@@ -938,6 +947,14 @@
{
err = iDatabase.Recover();
}
+ if(KErrNone == err)
+ {
+ err = iDatabase.Compact();
+ if(KErrNone != err)
+ {//the DB file is corrupt
+ BaflUtils::DeleteFile(iSingletons.Fs(), fullName);
+ }
+ }
}
if (err != KErrNone)