mtpfws/mtpfw/dataproviders/dputility/src/cmtpsendobjectinfo.cpp
changeset 31 a26669f87b46
parent 29 3ae5cb0b4c02
child 49 c20dd21d1eb4
--- a/mtpfws/mtpfw/dataproviders/dputility/src/cmtpsendobjectinfo.cpp	Fri Jun 25 16:54:01 2010 +0800
+++ b/mtpfws/mtpfw/dataproviders/dputility/src/cmtpsendobjectinfo.cpp	Fri Jul 09 17:58:21 2010 +0800
@@ -540,7 +540,7 @@
             }
         }
 
-    if (result)
+    if (result && !iIsFolder)
         {    
         result &= !Exists(iFullPath);
         if (!result)
@@ -613,7 +613,7 @@
             }
         }
         
-    if (result) 
+    if (result && !iIsFolder)
         {
         result = !Exists(iFullPath);
         if (!result)
@@ -1100,18 +1100,28 @@
     iReceivedObject->SetUint(CMTPObjectMetaData::EStorageId, iStorageId);
     iReceivedObject->SetDesCL(CMTPObjectMetaData::ESuid, iFullPath);
     
-    iFramework.ObjectMgr().ReserveObjectHandleL(*iReceivedObject, iObjectSize);    
-    
     if(iIsFolder)
         {
-        SetPropertiesL(); 
-        iFramework.ObjectMgr().CommitReservedObjectHandleL(*iReceivedObject);       
+        SetPropertiesL();
+        TUint32 handle = iFramework.ObjectMgr().HandleL(iFullPath);
+        if (handle != KMTPHandleNone)
+            {
+            // The folder is already in DB
+            iReceivedObject->SetUint(CMTPObjectMetaData::EHandle, handle);
+            iFramework.ObjectMgr().ModifyObjectL(*iReceivedObject);
+            }
+        else
+            {
+            iFramework.ObjectMgr().ReserveObjectHandleL(*iReceivedObject, iObjectSize);
+            iFramework.ObjectMgr().CommitReservedObjectHandleL(*iReceivedObject);
+            }
         }
     else
-    	{
-    	iExpectedSendObjectRequest.SetUint32(TMTPTypeRequest::ERequestSessionID, iSessionId);
-    	iFramework.RouteRequestRegisterL(iExpectedSendObjectRequest, iConnection);
-    	}
+        {
+        iFramework.ObjectMgr().ReserveObjectHandleL(*iReceivedObject, iObjectSize);    
+        iExpectedSendObjectRequest.SetUint32(TMTPTypeRequest::ERequestSessionID, iSessionId);
+        iFramework.RouteRequestRegisterL(iExpectedSendObjectRequest, iConnection);
+        }
     TUint32 parameters[3];
     parameters[0] = iStorageId;
     parameters[1] = iParentHandle;
@@ -1124,7 +1134,10 @@
     {
     if (iIsFolder)
         {
-        User::LeaveIfError(iFramework.Fs().MkDirAll(iFullPath));
+        if (!Exists(iFullPath))
+            {
+            User::LeaveIfError(iFramework.Fs().MkDirAll(iFullPath));
+            }
         }
     else
         {