[tracker] Turtle: Handle file errors
- From: Jürg Billeter <juergbi src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [tracker] Turtle: Handle file errors
- Date: Wed, 30 Sep 2009 17:46:38 +0000 (UTC)
commit 4c68187a63a723c4931dd41c69139cfc9d860281
Author: Jürg Billeter <j bitron ch>
Date: Wed Sep 30 19:45:18 2009 +0200
Turtle: Handle file errors
Fixes NB#132655.
src/libtracker-data/tracker-data-manager.c | 8 +++++++-
src/libtracker-data/tracker-turtle-reader.vala | 4 ++--
src/tracker-store/tracker-store.c | 17 ++++++++++++++---
utils/services/data-validator.c | 4 ++--
utils/services/ontology-validator.c | 2 +-
utils/services/ttl_loader.c | 4 ++--
6 files changed, 28 insertions(+), 11 deletions(-)
---
diff --git a/src/libtracker-data/tracker-data-manager.c b/src/libtracker-data/tracker-data-manager.c
index 953a5d8..5e31d04 100644
--- a/src/libtracker-data/tracker-data-manager.c
+++ b/src/libtracker-data/tracker-data-manager.c
@@ -73,7 +73,13 @@ load_ontology_file_from_path (const gchar *ontology_file)
TrackerTurtleReader *reader;
GError *error = NULL;
- reader = tracker_turtle_reader_new (ontology_file);
+ reader = tracker_turtle_reader_new (ontology_file, &error);
+ if (error) {
+ g_critical ("Turtle parse error: %s", error->message);
+ g_error_free (error);
+ return;
+ }
+
while (error == NULL && tracker_turtle_reader_next (reader, &error)) {
const gchar *subject, *predicate, *object;
diff --git a/src/libtracker-data/tracker-turtle-reader.vala b/src/libtracker-data/tracker-turtle-reader.vala
index 176c495..138c658 100644
--- a/src/libtracker-data/tracker-turtle-reader.vala
+++ b/src/libtracker-data/tracker-turtle-reader.vala
@@ -61,7 +61,7 @@ public class Tracker.TurtleReader : Object {
MappedFile? mapped_file;
- public TurtleReader (string path) {
+ public TurtleReader (string path) throws FileError {
mapped_file = new MappedFile (path, false);
scanner = new SparqlScanner (mapped_file.get_contents (), mapped_file.get_length ());
@@ -362,7 +362,7 @@ public class Tracker.TurtleReader : Object {
}
}
- public static void load (string path) throws SparqlError, DataError {
+ public static void load (string path) throws FileError, SparqlError, DataError {
try {
Data.begin_transaction ();
diff --git a/src/tracker-store/tracker-store.c b/src/tracker-store/tracker-store.c
index 4504dab..a31520f 100644
--- a/src/tracker-store/tracker-store.c
+++ b/src/tracker-store/tracker-store.c
@@ -230,13 +230,23 @@ queue_idle_handler (gpointer user_data)
GError *error = NULL;
static TrackerTurtleReader *turtle_reader = NULL;
- begin_batch (private);
-
if (!task->data.turtle.in_progress) {
- turtle_reader = tracker_turtle_reader_new (task->data.turtle.path);
+ turtle_reader = tracker_turtle_reader_new (task->data.turtle.path, &error);
+ if (error) {
+ if (task->callback.turtle_callback) {
+ task->callback.turtle_callback (error, task->user_data);
+ }
+
+ turtle_reader = NULL;
+ g_clear_error (&error);
+
+ goto out;
+ }
task->data.turtle.in_progress = TRUE;
}
+ begin_batch (private);
+
if (process_turtle_file_part (turtle_reader, &error)) {
/* import still in progress */
private->batch_count++;
@@ -265,6 +275,7 @@ queue_idle_handler (gpointer user_data)
}
}
+out:
g_queue_pop_head (private->queue);
if (task->destroy) {
diff --git a/utils/services/data-validator.c b/utils/services/data-validator.c
index a03fd0a..022c352 100644
--- a/utils/services/data-validator.c
+++ b/utils/services/data-validator.c
@@ -111,7 +111,7 @@ load_ontology_files (const gchar *services_dir)
fullpath = g_build_filename (dir_uri, conf_file, NULL);
- reader = tracker_turtle_reader_new (fullpath);
+ reader = tracker_turtle_reader_new (fullpath, NULL);
while (error == NULL && tracker_turtle_reader_next (reader, &error)) {
turtle_load_ontology (tracker_turtle_reader_get_subject (reader),
@@ -179,7 +179,7 @@ main (gint argc, gchar **argv)
TrackerTurtleReader *reader;
GError *error = NULL;
- reader = tracker_turtle_reader_new (ttl_file);
+ reader = tracker_turtle_reader_new (ttl_file, NULL);
while (error == NULL && tracker_turtle_reader_next (reader, &error)) {
turtle_statement_handler (tracker_turtle_reader_get_subject (reader),
diff --git a/utils/services/ontology-validator.c b/utils/services/ontology-validator.c
index 5944d32..3e316eb 100644
--- a/utils/services/ontology-validator.c
+++ b/utils/services/ontology-validator.c
@@ -131,7 +131,7 @@ process_file (const gchar *ttl_file)
g_print ("Processing %s\n", ttl_file);
- reader = tracker_turtle_reader_new (ttl_file);
+ reader = tracker_turtle_reader_new (ttl_file, NULL);
while (error == NULL && tracker_turtle_reader_next (reader, &error)) {
turtle_load_ontology (tracker_turtle_reader_get_subject (reader),
diff --git a/utils/services/ttl_loader.c b/utils/services/ttl_loader.c
index a82976c..8c70c21 100644
--- a/utils/services/ttl_loader.c
+++ b/utils/services/ttl_loader.c
@@ -231,7 +231,7 @@ ttl_loader_load_ontology (const gchar *ttl_file)
TrackerTurtleReader *reader;
GError *error = NULL;
- reader = tracker_turtle_reader_new (ttl_file);
+ reader = tracker_turtle_reader_new (ttl_file, NULL);
while (error == NULL && tracker_turtle_reader_next (reader, &error)) {
load_in_memory (ontology,
@@ -263,7 +263,7 @@ ttl_loader_load_description (const gchar *filename)
desc = ttl_model_description_new ();
- reader = tracker_turtle_reader_new (filename);
+ reader = tracker_turtle_reader_new (filename, NULL);
while (error == NULL && tracker_turtle_reader_next (reader, &error)) {
load_description (desc,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]