harvesterplugins/media/mediautils/src/cpixindexerutils.cpp
changeset 26 367228f82b66
parent 18 1edf350003c5
--- a/harvesterplugins/media/mediautils/src/cpixindexerutils.cpp	Tue Sep 28 11:50:55 2010 +0530
+++ b/harvesterplugins/media/mediautils/src/cpixindexerutils.cpp	Tue Oct 05 13:32:14 2010 +0530
@@ -28,6 +28,7 @@
 // local declarations and functions
 namespace {
 _LIT(KCPixSearchServerPrivateDirectory, "\\Private\\2001f6f7\\");
+_LIT(KIndexingDBPath,"indexing\\indexdb");
 _LIT(KPathIndexDbPath, CPIX_INDEVICE_INDEXDB);
 
 _LIT(KAtSign, "@");
@@ -276,6 +277,8 @@
         }
     if(IsDriveCanbeMountedL(aMedia))
         {
+        //clean the existing database if any
+        RemoveUnmountedDatabaseL(aMedia,aPath);
         // Form the baseappclass for this media
         TBuf<KMsgPluginBaseAppClassMaxLen> baseAppClass;
         FormBaseAppClass(TDriveNumber(aMedia), aBaseAppClassGeneric,baseAppClass);
@@ -467,4 +470,30 @@
     return iMountedDrives;
     }
 
+// -----------------------------------------------------------------------------
+// CCPixIndexerUtils::RemoveUnmountedDatabase()
+// -----------------------------------------------------------------------------
+//
+void CCPixIndexerUtils::RemoveUnmountedDatabaseL(TDriveNumber aMedia, const TDesC& aPath)
+    {
+    RFs aFs;
+    User::LeaveIfError( aFs.Connect() );
+    TChar drive;
+    TInt err = aFs.DriveToChar((TDriveNumber)aMedia,drive);
+    if ( err == KErrNone )
+        {
+        TBuf<KMaxFileName> folderpath;
+        folderpath.Append(drive);
+        folderpath.Append(KColon);
+        folderpath.Append(KCPixSearchServerPrivateDirectory);
+        folderpath.Append(KIndexingDBPath);
+        folderpath.Append(aPath);
+        CFileMan* FileMan = CFileMan::NewL(aFs);
+        if ( FileMan )
+            FileMan->Delete( folderpath );
+        delete FileMan;
+        }
+    aFs.Close();
+    }
+
 //End of file