[tracker] Passing errors for Turtle import to DBus caller
- From: Philip Van Hoof <pvanhoof src gnome org>
- To: svn-commits-list gnome org
- Subject: [tracker] Passing errors for Turtle import to DBus caller
- Date: Thu, 16 Jul 2009 09:30:48 +0000 (UTC)
commit 0b7aec0aec9712fbcdbec76e70161c5e1da884c2
Author: Philip Van Hoof <philip codeminded be>
Date: Thu Jul 16 11:30:12 2009 +0200
Passing errors for Turtle import to DBus caller
src/libtracker-data/tracker-turtle.c | 45 +++++++++++++++++++++++++--------
src/libtracker-data/tracker-turtle.h | 1 +
src/tracker-store/tracker-store.c | 5 +++-
3 files changed, 39 insertions(+), 12 deletions(-)
---
diff --git a/src/libtracker-data/tracker-turtle.c b/src/libtracker-data/tracker-turtle.c
index d454ef3..20ea83f 100644
--- a/src/libtracker-data/tracker-turtle.c
+++ b/src/libtracker-data/tracker-turtle.c
@@ -31,6 +31,8 @@
#include <uuid.h>
+#include <libtracker-data/tracker-data-update.h>
+
#include "tracker-turtle.h"
static gboolean initialized = FALSE;
@@ -42,6 +44,7 @@ static gchar * volatile turtle_subject;
static gchar * volatile turtle_predicate;
static char * volatile turtle_object;
static raptor_identifier_type volatile turtle_object_type;
+static GError *raptor_error = NULL;
static volatile gboolean turtle_eof;
static volatile gboolean turtle_cancel;
@@ -276,15 +279,19 @@ tracker_turtle_close (TurtleFile *turtle)
}
static void
-raptor_error (void *user_data,
- raptor_locator *locator,
- const gchar *message)
+raptor_error_handler (void *user_data,
+ raptor_locator *locator,
+ const gchar *message)
{
- g_message ("RAPTOR parse error: %s:%d:%d: %s\n",
- (gchar *) user_data,
- locator->line,
- locator->column,
- message);
+ g_set_error (&raptor_error, TRACKER_DATA_ERROR,
+ TRACKER_DATA_ERROR_UNKNOWN_PROPERTY,
+ "RAPTOR parse error: %s:%d:%d: %s\n",
+ (gchar *) user_data,
+ locator->line,
+ locator->column,
+ message);
+
+ turtle_cancel = TRUE;
}
static unsigned char*
@@ -395,9 +402,9 @@ turtle_thread_func (gpointer data)
raptor_set_statement_handler (parser, parser, (raptor_statement_handler) turtle_statement_handler);
raptor_set_generate_id_handler (parser, base_uuid, turtle_generate_id);
- raptor_set_fatal_error_handler (parser, (void *)thread_data->file, raptor_error);
- raptor_set_error_handler (parser, (void *)thread_data->file, raptor_error);
- raptor_set_warning_handler (parser, (void *)thread_data->file, raptor_error);
+ raptor_set_fatal_error_handler (parser, (void *)thread_data->file, raptor_error_handler);
+ raptor_set_error_handler (parser, (void *)thread_data->file, raptor_error_handler);
+ raptor_set_warning_handler (parser, (void *)thread_data->file, raptor_error_handler);
uri_string = raptor_uri_filename_to_uri_string (thread_data->file);
uri = raptor_new_uri (uri_string);
@@ -454,6 +461,7 @@ tracker_turtle_process (const gchar *turtle_file,
g_return_if_fail (turtle_mutex == NULL);
+ g_clear_error (&raptor_error);
turtle_mutex = g_mutex_new ();
turtle_cond = g_cond_new ();
@@ -474,6 +482,7 @@ tracker_turtle_process (const gchar *turtle_file,
turtle_eof = FALSE;
+ g_clear_error (&raptor_error);
g_mutex_free (turtle_mutex);
g_cond_free (turtle_cond);
turtle_mutex = NULL;
@@ -551,6 +560,7 @@ tracker_turtle_reader_init (const gchar *turtle_file,
g_return_if_fail (turtle_mutex == NULL);
+ g_clear_error (&raptor_error);
turtle_mutex = g_mutex_new ();
turtle_cond = g_cond_new ();
@@ -574,6 +584,7 @@ tracker_turtle_reader_next (void)
turtle_eof = FALSE;
+ g_clear_error (&raptor_error);
g_mutex_free (turtle_mutex);
g_cond_free (turtle_cond);
turtle_mutex = NULL;
@@ -593,6 +604,18 @@ tracker_turtle_reader_cancel (void)
}
}
+GError*
+tracker_turtle_get_error (void)
+{
+ GError *error = NULL;
+
+ if (raptor_error) {
+ error = g_error_copy (raptor_error);
+ }
+
+ return error;
+}
+
const gchar *
tracker_turtle_reader_get_subject (void)
{
diff --git a/src/libtracker-data/tracker-turtle.h b/src/libtracker-data/tracker-turtle.h
index 0f736f8..6959840 100644
--- a/src/libtracker-data/tracker-turtle.h
+++ b/src/libtracker-data/tracker-turtle.h
@@ -61,6 +61,7 @@ const gchar *tracker_turtle_reader_get_predicate (void);
const gchar *tracker_turtle_reader_get_object (void);
gboolean tracker_turtle_reader_object_is_uri (void);
void tracker_turtle_reader_cancel (void);
+GError* tracker_turtle_get_error (void);
/* Optimizer, reparser */
void tracker_turtle_optimize (const gchar *turtle_file);
diff --git a/src/tracker-store/tracker-store.c b/src/tracker-store/tracker-store.c
index 6e66cee..01921bb 100644
--- a/src/tracker-store/tracker-store.c
+++ b/src/tracker-store/tracker-store.c
@@ -90,11 +90,12 @@ static gboolean
process_turtle_file_part (GError **error)
{
int i;
- GError *new_error = NULL;
+ GError *new_error;
/* process 10 statements at once before returning to main loop */
i = 0;
+ new_error = tracker_turtle_get_error ();
while (!new_error && tracker_turtle_reader_next ()) {
/* insert statement */
@@ -112,6 +113,8 @@ process_turtle_file_part (GError **error)
&new_error);
}
+ new_error = tracker_turtle_get_error ();
+
i++;
if (!new_error && i >= 10) {
/* return to main loop */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]