[tracker] libtracker-data: Update mtime of db-version.txt after a backup restoration



commit 6e4dfe01530d4289429a79d10471c09dbea60835
Author: Aleksander Morgado <aleksander lanedo com>
Date:   Mon Jan 31 12:51:38 2011 +0100

    libtracker-data: Update mtime of db-version.txt after a backup restoration
    
    Fixes NB#223622

 src/libtracker-data/tracker-data-backup.c |    4 ++++
 src/libtracker-data/tracker-db-manager.c  |   28 ++++++++++++++--------------
 src/libtracker-data/tracker-db-manager.h  |    1 +
 3 files changed, 19 insertions(+), 14 deletions(-)
---
diff --git a/src/libtracker-data/tracker-data-backup.c b/src/libtracker-data/tracker-data-backup.c
index fbc78d1..4b3ea8b 100644
--- a/src/libtracker-data/tracker-data-backup.c
+++ b/src/libtracker-data/tracker-data-backup.c
@@ -392,6 +392,10 @@ tracker_data_backup_restore (GFile                *journal,
 		                           busy_callback, busy_user_data,
 		                           "Restoring backup");
 
+		/* 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 ();
 	} else {
 		g_set_error (&info->error, TRACKER_DATA_BACKUP_ERROR, 0,
 		             "Backup file doesn't exist");
diff --git a/src/libtracker-data/tracker-db-manager.c b/src/libtracker-data/tracker-db-manager.c
index 98d9096..8b0baab 100644
--- a/src/libtracker-data/tracker-db-manager.c
+++ b/src/libtracker-data/tracker-db-manager.c
@@ -437,17 +437,6 @@ db_manager_remove_all (gboolean rm_journal)
 	db_remove_locale_file ();
 }
 
-void
-tracker_db_manager_remove_version_file (void)
-{
-	gchar *filename;
-
-	filename = g_build_filename (data_dir, TRACKER_DB_VERSION_FILE, NULL);
-	g_message ("  Removing db-version file:'%s'", filename);
-	g_unlink (filename);
-	g_free (filename);
-}
-
 static TrackerDBVersion
 db_get_version (void)
 {
@@ -487,8 +476,8 @@ db_get_version (void)
 	return version;
 }
 
-static void
-db_set_version (void)
+void
+tracker_db_manager_create_version_file (void)
 {
 	GError *error = NULL;
 	gchar  *filename;
@@ -509,6 +498,17 @@ db_set_version (void)
 	g_free (filename);
 }
 
+void
+tracker_db_manager_remove_version_file (void)
+{
+	gchar *filename;
+
+	filename = g_build_filename (data_dir, TRACKER_DB_VERSION_FILE, NULL);
+	g_message ("  Removing db-version file:'%s'", filename);
+	g_unlink (filename);
+	g_free (filename);
+}
+
 static void
 db_remove_locale_file (void)
 {
@@ -815,7 +815,7 @@ tracker_db_manager_init (TrackerDBManagerFlags  flags,
 	}
 
 	if (need_reindex) {
-		db_set_version ();
+		tracker_db_manager_create_version_file ();
 	}
 
 	g_message ("Checking database files exist");
diff --git a/src/libtracker-data/tracker-db-manager.h b/src/libtracker-data/tracker-db-manager.h
index dbf240f..630c80a 100644
--- a/src/libtracker-data/tracker-db-manager.h
+++ b/src/libtracker-data/tracker-db-manager.h
@@ -68,6 +68,7 @@ void                tracker_db_manager_move_to_temp           (void);
 void                tracker_db_manager_restore_from_temp      (void);
 void                tracker_db_manager_init_locations         (void);
 gboolean            tracker_db_manager_has_enough_space       (void);
+void                tracker_db_manager_create_version_file    (void);
 void                tracker_db_manager_remove_version_file    (void);
 
 void                tracker_db_manager_lock                   (void);



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