mtpfws/mtpfw/dataproviders/dputility/src/cmtpsendobjectinfo.cpp
branchRCL_3
changeset 17 dbd1c5e08735
parent 12 523717cdb0ad
--- a/mtpfws/mtpfw/dataproviders/dputility/src/cmtpsendobjectinfo.cpp	Mon Jun 21 16:36:59 2010 +0300
+++ b/mtpfws/mtpfw/dataproviders/dputility/src/cmtpsendobjectinfo.cpp	Thu Jul 15 19:35:12 2010 +0300
@@ -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
         {