Revision: 201025 RCL_3
authorDremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Thu, 15 Jul 2010 19:11:10 +0300
branchRCL_3
changeset 20 e4175d61d967
parent 18 b9e74fff3740
child 21 e5b3a2155e1a
Revision: 201025 Kit: 2010127
messagingfw/msgsrvnstore/server/src/CMsvCachedStore.cpp
messagingfw/msgsrvnstore/server/src/MTCLBASE.CPP
messagingfw/msgsrvnstore/server/src/TMsvServerStoreManager.cpp
--- a/messagingfw/msgsrvnstore/server/src/CMsvCachedStore.cpp	Mon Jun 21 16:13:01 2010 +0300
+++ b/messagingfw/msgsrvnstore/server/src/CMsvCachedStore.cpp	Thu Jul 15 19:11:10 2010 +0300
@@ -620,16 +620,13 @@
 	RFileWriteStream out(tempStoreFile);
 	out.PushL();
 	WriteToFileStreamL(out);
-	CleanupStack::PopAndDestroy(&out); // close RFileWriteStream out
-	iStoreManager.ReplaceFileStoreL(iEntryId);
 
-	// Need the size
-	RFile storeFile;
-	User::LeaveIfError(iStoreManager.OpenFileStoreForRead(iEntryId, storeFile));
-	CleanupClosePushL(storeFile);
-	User::LeaveIfError(storeFile.Size(iSize));
-	CleanupStack::PopAndDestroy(&storeFile);
+	//get the size of the stream, in previous call the Stream is already commited to the file, the next step simply replace the file with this temp new file so size should be the same
+	//the SizeL in this case will not involve any file i/o calls.
+	iSize=out.Sink()->SizeL();
 	
+    CleanupStack::PopAndDestroy(&out); // close RFileWriteStream out
+    iStoreManager.ReplaceFileStoreL(iEntryId);
 
 	}
 
--- a/messagingfw/msgsrvnstore/server/src/MTCLBASE.CPP	Mon Jun 21 16:13:01 2010 +0300
+++ b/messagingfw/msgsrvnstore/server/src/MTCLBASE.CPP	Thu Jul 15 19:11:10 2010 +0300
@@ -687,10 +687,12 @@
 */	
 EXPORT_C void CBaseMtm::CancelAttachmentOperation()
 	{
-	__ASSERT_ALWAYS(iAttachmentWaiter != NULL, PanicServer(EMsvOperationNotFound));
-	iAttachmentWaiter->Cancel();
-	delete iAttachmentWaiter;
-	iAttachmentWaiter = NULL;
+	if(iAttachmentWaiter)
+		{
+		iAttachmentWaiter->Cancel();
+		delete iAttachmentWaiter;
+		iAttachmentWaiter = NULL;
+		}
 	}
 
 
--- a/messagingfw/msgsrvnstore/server/src/TMsvServerStoreManager.cpp	Mon Jun 21 16:13:01 2010 +0300
+++ b/messagingfw/msgsrvnstore/server/src/TMsvServerStoreManager.cpp	Thu Jul 15 19:11:10 2010 +0300
@@ -381,11 +381,17 @@
 	GetStoreFileName(aEntryId,tempFilePathAndName);
 
 	tempFilePathAndName.Append(KMsvUtilsNewExtension);
-	TInt error = iFs->MkDirAll(tempFilePathAndName);
-	if(error == KErrNone || error == KErrAlreadyExists)
-		error = aFile.Replace(*iFs,tempFilePathAndName,EFileShareExclusive|EFileWrite);
-
+	
+	TInt error= aFile.Replace(*iFs,tempFilePathAndName,EFileShareExclusive|EFileWrite);
+	if (error==KErrPathNotFound)
+	{
+        //only create directory if not found
+        error=iFs->MkDirAll(tempFilePathAndName);
+        if (error==KErrNone)
+            error=aFile.Replace(*iFs,tempFilePathAndName,EFileShareExclusive|EFileWrite);
+	}
 	User::LeaveIfError(error);
+	
 	}
 
 void TMsvServerStoreManager::ReplaceFileStoreL(TMsvId aEntryId)