mpxplugins/serviceplugins/collectionplugins/mpxsqlitedbhgplugin/src/mpxdbplugin.cpp
branchRCL_3
changeset 66 1f1dad4af8f8
parent 53 3de6c4cf6b67
--- a/mpxplugins/serviceplugins/collectionplugins/mpxsqlitedbhgplugin/src/mpxdbplugin.cpp	Wed Sep 15 12:09:46 2010 +0300
+++ b/mpxplugins/serviceplugins/collectionplugins/mpxsqlitedbhgplugin/src/mpxdbplugin.cpp	Wed Oct 13 14:28:40 2010 +0300
@@ -3989,13 +3989,38 @@
     switch(table)
         {
         case EMPXCollectionCountTrack:
-            count = (TInt)iDbHandler->GetMusicCountL(drive);
+            TRAPD( trackerr, count = (TInt)iDbHandler->GetMusicCountL(drive) );
+            MPX_DEBUG2( "CMPXDbPlugin::DoGetCollectionCountL, trackerr =%d", trackerr );
+            if ( trackerr == KErrCorrupt )
+                {
+                iDbHandler->CloseDatabaseL( drive );
+                iDbHandler->RecreateDatabaseFileL( drive );
+                iDbHandler->OpenDatabaseL( drive );
+                count = (TInt)iDbHandler->GetMusicCountL(drive);
+                }
+            
             break;
         case EMPXCollectionCountPlaylist:
-            count = (TInt)iDbHandler->GetPlaylistCountL(drive);
+            TRAPD( playlisterr, count = (TInt)iDbHandler->GetPlaylistCountL(drive) );
+            MPX_DEBUG2( "CMPXDbPlugin::DoGetCollectionCountL, playlisterr =%d", playlisterr );
+            if ( playlisterr == KErrCorrupt )
+                {
+                iDbHandler->CloseDatabaseL( drive );
+                iDbHandler->RecreateDatabaseFileL( drive );
+                iDbHandler->OpenDatabaseL( drive );
+                count = (TInt)iDbHandler->GetPlaylistCountL(drive);
+                }
             break;
         case EMPXCollectionCountTotal:
-            count = (TInt)iDbHandler->GetTotalCountL(drive);
+            TRAPD( totalerr, count = (TInt)iDbHandler->GetTotalCountL(drive) );
+            MPX_DEBUG2( "CMPXDbPlugin::DoGetCollectionCountL, totalerr =%d", totalerr );
+            if ( totalerr == KErrCorrupt )
+                {
+                iDbHandler->CloseDatabaseL( drive );
+                iDbHandler->RecreateDatabaseFileL( drive );
+                iDbHandler->OpenDatabaseL( drive );
+                count = (TInt)iDbHandler->GetTotalCountL(drive);
+                }
             break;
         default:
             User::Leave(KErrArgument);