persistentstorage/centralrepository/cenrepsrv/backup.cpp
changeset 40 b8bdbc8f59c7
parent 0 08ec8eefde2f
child 45 cc28652e0254
child 55 44f437012c90
--- a/persistentstorage/centralrepository/cenrepsrv/backup.cpp	Thu Jul 08 12:09:58 2010 +0100
+++ b/persistentstorage/centralrepository/cenrepsrv/backup.cpp	Thu Aug 12 11:53:23 2010 +0100
@@ -385,6 +385,15 @@
 	}
 
 
+void CRepositoryBackupClient::RestoreRepositoryAndListL(TUid repositoryUid, CDirectFileStore* store, TStreamId settingsStreamId, TStreamId deletedSettingsStreamId, TInt& repIndex)
+    {
+    // Add the restored repository to the restored repositories list.
+    // Pass its changed-keys list to further restoring functions to add entries for post-restoration notification.
+    repIndex = AddRestoredRepositoryL(repositoryUid);
+    iRepository->RestoreRepositoryContentsL(*store, settingsStreamId, deletedSettingsStreamId, *iRestoredRepositoriesArray[repIndex]);
+    iRepository->CommitChangesL();
+    }
+
 	
 //
 // CRepositoryBackupClient::RestoreCompleteL
@@ -420,7 +429,6 @@
 		}		
 
 
-
 	// Get the root stream and attempt to read a backup file header from it
 	TStreamId rootStreamId = store->Root() ;
 	RStoreReadStream rootStream ;
@@ -462,8 +470,8 @@
 	
 	// Iterate through index and attempt restore of each repository stream
 	// we find in it.
-	restoreStreamIndex->Reset() ;	
-	TUid repositoryUid ;
+	restoreStreamIndex->Reset();	
+	TUid repositoryUid;
 	TStreamId settingsStreamId(KNullStreamIdValue);
 	TStreamId deletedSettingsStreamId(KNullStreamIdValue);
 	TStreamId installedSettingsStreamId(KNullStreamIdValue);
@@ -472,12 +480,10 @@
 		{
 		iRepository->OpenL(repositoryUid, *iNotifier, EFalse);
 		iRepository->FailAllTransactions();
-		// Add the restored repository to the restored repositories list.
-		// Pass its changed-keys list to further restoring functions to add entries for post-restoration notification.
-		TInt repIndex = AddRestoredRepositoryL(repositoryUid);
-		iRepository->RestoreRepositoryContentsL(*store, settingsStreamId, deletedSettingsStreamId, *iRestoredRepositoriesArray[repIndex]);
-		iRepository->CommitChangesL();
+		TInt repIndex;
+		TRAPD(err, RestoreRepositoryAndListL(repositoryUid, store, settingsStreamId, deletedSettingsStreamId, repIndex));
 		iRepository->Close();
+	    User::LeaveIfError(err);
 		// If the backup contains an installed repository containing default values for the settings, read them in
 		if (installedSettingsStreamId != KNullStreamId)
 			{