[tracker] libtracker-data: Progress handling while performing integrity check
- From: Philip Van Hoof <pvanhoof src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker] libtracker-data: Progress handling while performing integrity check
- Date: Tue, 12 Oct 2010 15:15:21 +0000 (UTC)
commit 30f1fa7b509f3bd284e46b246096bb60292f361c
Author: Philip Van Hoof <philip codeminded be>
Date: Thu Sep 30 16:28:59 2010 +0200
libtracker-data: Progress handling while performing integrity check
src/libtracker-data/tracker-data-manager.c | 3 +-
src/libtracker-data/tracker-data-update.h | 3 --
src/libtracker-data/tracker-db-interface-sqlite.c | 28 +++++++++++++++++++++
src/libtracker-data/tracker-db-interface.h | 9 ++++++
src/libtracker-data/tracker-db-manager.c | 11 +++++++-
src/libtracker-data/tracker-db-manager.h | 4 ++-
src/tracker-control/tracker-control.c | 2 +-
7 files changed, 53 insertions(+), 7 deletions(-)
---
diff --git a/src/libtracker-data/tracker-data-manager.c b/src/libtracker-data/tracker-data-manager.c
index 9915e07..32787a9 100644
--- a/src/libtracker-data/tracker-data-manager.c
+++ b/src/libtracker-data/tracker-data-manager.c
@@ -2794,7 +2794,8 @@ tracker_data_manager_init (TrackerDBManagerFlags flags,
read_journal = FALSE;
if (!tracker_db_manager_init (flags, &is_first_time_index, FALSE,
- select_cache_size, update_cache_size)) {
+ select_cache_size, update_cache_size,
+ busy_callback, busy_user_data)) {
return FALSE;
}
diff --git a/src/libtracker-data/tracker-data-update.h b/src/libtracker-data/tracker-data-update.h
index aaed202..512d567 100644
--- a/src/libtracker-data/tracker-data-update.h
+++ b/src/libtracker-data/tracker-data-update.h
@@ -44,9 +44,6 @@ typedef void (*TrackerStatementCallback) (gint graph_id,
GPtrArray *rdf_types,
gpointer user_data);
typedef void (*TrackerCommitCallback) (gpointer user_data);
-typedef void (*TrackerBusyCallback) (const gchar *status,
- gdouble progress,
- gpointer user_data);
GQuark tracker_data_error_quark (void);
diff --git a/src/libtracker-data/tracker-db-interface-sqlite.c b/src/libtracker-data/tracker-db-interface-sqlite.c
index e197f69..bb6998a 100644
--- a/src/libtracker-data/tracker-db-interface-sqlite.c
+++ b/src/libtracker-data/tracker-db-interface-sqlite.c
@@ -69,6 +69,10 @@ struct TrackerDBInterface {
TrackerDBStatementLru select_stmt_lru;
TrackerDBStatementLru update_stmt_lru;
+
+ TrackerBusyCallback busy_callback;
+ gpointer busy_user_data;
+ gchar *busy_status;
};
struct TrackerDBInterfaceClass {
@@ -510,6 +514,13 @@ static int
check_interrupt (void *user_data)
{
TrackerDBInterface *db_interface = user_data;
+
+ if (db_interface->busy_callback) {
+ db_interface->busy_callback (db_interface->busy_status,
+ 0.5, /* No idea to get the status from SQLite */
+ db_interface->busy_user_data);
+ }
+
return g_cancellable_is_cancelled (db_interface->cancellable) ? 1 : 0;
}
@@ -719,6 +730,7 @@ tracker_db_interface_sqlite_finalize (GObject *object)
g_message ("Closed sqlite3 database:'%s'", db_interface->filename);
g_free (db_interface->filename);
+ g_free (db_interface->busy_status);
tracker_collation_shutdown (db_interface->collator);
@@ -849,6 +861,22 @@ tracker_db_interface_set_max_stmt_cache_size (TrackerDBInterface *db_int
stmt_lru->max = 3;
}
+void
+tracker_db_interface_set_busy_handler (TrackerDBInterface *db_interface,
+ TrackerBusyCallback busy_callback,
+ const gchar *busy_status,
+ gpointer busy_user_data)
+{
+ g_return_if_fail (TRACKER_IS_DB_INTERFACE (db_interface));
+ db_interface->busy_callback = busy_callback;
+ db_interface->busy_user_data = busy_user_data;
+ g_free (db_interface->busy_status);
+ if (busy_status)
+ db_interface->busy_status = g_strdup (busy_status);
+ else
+ db_interface->busy_status = NULL;
+}
+
TrackerDBStatement *
tracker_db_interface_create_statement (TrackerDBInterface *db_interface,
TrackerDBStatementCacheType cache_type,
diff --git a/src/libtracker-data/tracker-db-interface.h b/src/libtracker-data/tracker-db-interface.h
index 3575fff..d80b2c0 100644
--- a/src/libtracker-data/tracker-db-interface.h
+++ b/src/libtracker-data/tracker-db-interface.h
@@ -63,6 +63,10 @@ G_BEGIN_DECLS
#define TRACKER_DB_INTERFACE_ERROR (tracker_db_interface_error_quark ())
+typedef void (*TrackerBusyCallback) (const gchar *status,
+ gdouble progress,
+ gpointer user_data);
+
typedef enum {
TRACKER_DB_QUERY_ERROR,
TRACKER_DB_CORRUPT,
@@ -134,6 +138,11 @@ TrackerDBCursor * tracker_db_statement_start_sparql_cursor (TrackerDBS
const gchar **variable_names,
gint n_variable_names,
GError **error);
+void tracker_db_interface_set_busy_handler (TrackerDBInterface *db_interface,
+ TrackerBusyCallback busy_callback,
+ const gchar *busy_status,
+ gpointer busy_user_data);
+
/* Semi private TrackerDBResultSet functions */
TrackerDBResultSet * _tracker_db_result_set_new (guint cols);
void _tracker_db_result_set_append (TrackerDBResultSet *result_set);
diff --git a/src/libtracker-data/tracker-db-manager.c b/src/libtracker-data/tracker-db-manager.c
index 49f40e0..c09cad2 100644
--- a/src/libtracker-data/tracker-db-manager.c
+++ b/src/libtracker-data/tracker-db-manager.c
@@ -699,7 +699,9 @@ tracker_db_manager_init (TrackerDBManagerFlags flags,
gboolean *first_time,
gboolean shared_cache,
guint select_cache_size,
- guint update_cache_size)
+ guint update_cache_size,
+ TrackerBusyCallback busy_callback,
+ gpointer busy_user_data)
{
GType etype;
TrackerDBVersion version;
@@ -910,6 +912,11 @@ tracker_db_manager_init (TrackerDBManagerFlags flags,
loaded = TRUE;
+ tracker_db_interface_set_busy_handler (dbs[i].iface,
+ busy_callback,
+ "Integrity checking",
+ busy_user_data);
+
stmt = tracker_db_interface_create_statement (dbs[i].iface, TRACKER_DB_STATEMENT_CACHE_TYPE_NONE, &error,
"PRAGMA integrity_check(1)");
@@ -940,6 +947,8 @@ tracker_db_manager_init (TrackerDBManagerFlags flags,
g_object_unref (cursor);
}
}
+
+ tracker_db_interface_set_busy_handler (dbs[i].iface, NULL, NULL, NULL);
}
}
diff --git a/src/libtracker-data/tracker-db-manager.h b/src/libtracker-data/tracker-db-manager.h
index 407564f..70e8977 100644
--- a/src/libtracker-data/tracker-db-manager.h
+++ b/src/libtracker-data/tracker-db-manager.h
@@ -54,7 +54,9 @@ gboolean tracker_db_manager_init (TrackerDBManagerF
gboolean *first_time,
gboolean shared_cache,
guint select_cache_size,
- guint update_cache_size);
+ guint update_cache_size,
+ TrackerBusyCallback busy_callback,
+ gpointer busy_user_data);
void tracker_db_manager_shutdown (void);
void tracker_db_manager_remove_all (gboolean rm_journal);
void tracker_db_manager_optimize (void);
diff --git a/src/tracker-control/tracker-control.c b/src/tracker-control/tracker-control.c
index ece1e93..ce5d079 100644
--- a/src/tracker-control/tracker-control.c
+++ b/src/tracker-control/tracker-control.c
@@ -439,7 +439,7 @@ main (int argc, char **argv)
g_object_unref (db_config);
/* Clean up (select_cache_size and update_cache_size don't matter here) */
- if (!tracker_db_manager_init (TRACKER_DB_MANAGER_REMOVE_ALL, NULL, FALSE, 100, 100)) {
+ if (!tracker_db_manager_init (TRACKER_DB_MANAGER_REMOVE_ALL, NULL, FALSE, 100, 100, NULL, NULL)) {
return EXIT_FAILURE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]