[tracker/checkpoint: 15/17] libtracker-data: Fix recover from restore failure



commit 0ea3eddd66fa05870c33080073cc35afc7921489
Author: JÃrg Billeter <j bitron ch>
Date:   Mon Jun 27 12:54:39 2011 +0200

    libtracker-data: Fix recover from restore failure

 src/libtracker-data/tracker-data-backup.c |   35 +++++++++++++++++++----------
 1 files changed, 23 insertions(+), 12 deletions(-)
---
diff --git a/src/libtracker-data/tracker-data-backup.c b/src/libtracker-data/tracker-data-backup.c
index f821ff3..45c7eeb 100644
--- a/src/libtracker-data/tracker-data-backup.c
+++ b/src/libtracker-data/tracker-data-backup.c
@@ -611,6 +611,16 @@ tracker_data_backup_restore (GFile                *journal,
 
 		tracker_db_manager_init_locations ();
 
+		/* Re-set the DB version file, so that its mtime changes. The mtime of this
+		 * file will change only when the whole DB is recreated (after a hard reset
+		 * or after a backup restoration). */
+		tracker_db_manager_create_version_file ();
+
+		/* Given we're radically changing the database, we
+		 * force a full mtime check against all known files in
+		 * the database for complete synchronisation. */
+		tracker_db_manager_set_need_mtime_check (TRUE);
+
 #ifndef DISABLE_JOURNAL
 		tracker_db_journal_init (NULL, FALSE, &n_error);
 
@@ -624,7 +634,6 @@ tracker_data_backup_restore (GFile                *journal,
 			}
 			n_error = NULL;
 		}
-#endif /* DISABLE_JOURNAL */
 
 		if (info->error) {
 			restore_from_temp ();
@@ -632,7 +641,6 @@ tracker_data_backup_restore (GFile                *journal,
 			remove_temp ();
 		}
 
-#ifndef DISABLE_JOURNAL
 		tracker_db_journal_shutdown (&n_error);
 
 		if (n_error) {
@@ -647,18 +655,21 @@ tracker_data_backup_restore (GFile                *journal,
 		                           busy_callback, busy_user_data,
 		                           "Restoring backup", &internal_error);
 
+#ifdef DISABLE_JOURNAL
 		if (internal_error) {
-			g_propagate_error (error, internal_error);
+			restore_from_temp ();
+
+			tracker_data_manager_init (flags, test_schemas, &is_first, TRUE, TRUE,
+			                           select_cache_size, update_cache_size,
+			                           busy_callback, busy_user_data,
+			                           "Restoring backup", &internal_error);
 		} else {
-			/* Re-set the DB version file, so that its mtime changes. The mtime of this
-			 * file will change only when the whole DB is recreated (after a hard reset
-			 * or after a backup restoration). */
-			tracker_db_manager_create_version_file ();
-
-			/* Given we're radically changing the database, we
-			 * force a full mtime check against all known files in
-			 * the database for complete synchronisation. */
-			tracker_db_manager_set_need_mtime_check (TRUE);
+			remove_temp ();
+		}
+#endif /* DISABLE_JOURNAL */
+
+		if (internal_error) {
+			g_propagate_error (error, internal_error);
 		}
 	} else {
 		g_set_error (&info->error, TRACKER_DATA_BACKUP_ERROR,



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]