persistentstorage/store/UFILE/UF_DICT.CPP
changeset 35 0d6db0a14001
parent 0 08ec8eefde2f
child 55 44f437012c90
--- a/persistentstorage/store/UFILE/UF_DICT.CPP	Fri Jun 11 15:29:22 2010 +0300
+++ b/persistentstorage/store/UFILE/UF_DICT.CPP	Tue Jul 06 16:18:30 2010 +0300
@@ -154,7 +154,11 @@
 	for (TInt wait=KLockoutLimit;;)
 		{
 		RFile file;
-		TInt r=file.Open(aFs,aName,EFileShareExclusive|EFileWrite);
+        //  When the file server write caching is enabled, the order of file write operations is not guaranteed.
+        // This could cause data inconsistency in some circumstances,for example, when the power is lost in the 
+        // middle of a database transaction.Therefore, the file write caching is disabled for this file to maintain integrity.
+
+		TInt r=file.Open(aFs,aName,EFileShareExclusive|EFileWrite|EFileWriteDirectIO);
 		switch (r)
 			{
 		case KErrNone:
@@ -175,8 +179,12 @@
 					}
 				if (r==KErrCorrupt)
 					{
-					// silently replace the entire file if it is corrupt
-					r=file.Replace(aFs,aName,EFileShareExclusive|EFileWrite);
+				// silently replace the entire file if it is corrupt
+				//  When the file server write caching is enabled, the order of file write operations is not guaranteed.
+				// This could cause data inconsistency in some circumstances,for example, when the power is lost in the 
+				// middle of a database transaction.Therefore, the file write caching is disabled for this file to maintain integrity.
+				//   
+					r=file.Replace(aFs,aName,EFileShareExclusive|EFileWrite|EFileWriteDirectIO);
 					if (r==KErrInUse)
 						break;  // try again later...
 					if (r==KErrNone)
@@ -197,7 +205,10 @@
 			return;
 			}
 		case KErrNotFound:
-			r=file.Create(aFs,aName,EFileShareExclusive|EFileWrite);
+            //  When the file server write caching is enabled, the order of file write operations is not guaranteed.
+            // This could cause data inconsistency in some circumstances,for example, when the power is lost in the 
+            // middle of a database transaction.Therefore, the file write caching is disabled for this file to maintain integrity.
+			r=file.Create(aFs,aName,EFileShareExclusive|EFileWrite|EFileWriteDirectIO);
 			if (r==KErrNone)
 				{
 				CreateStoreL(file,type);