[tracker/on-extractor-error: 3/3] miners/fs: Don't set IE properties in case of error



commit 309292c002c5a9e7363622e14dc9a6d4f1801975
Author: Philip Van Hoof <philip codeminded be>
Date:   Tue May 3 17:30:36 2011 +0200

    miners/fs: Don't set IE properties in case of error
    
    This commit doesn't have to be ported to tracker-0.10

 src/miners/fs/tracker-miner-files.c |   35 +++++++++++++++++++++--------------
 1 files changed, 21 insertions(+), 14 deletions(-)
---
diff --git a/src/miners/fs/tracker-miner-files.c b/src/miners/fs/tracker-miner-files.c
index d465ee2..0335045 100644
--- a/src/miners/fs/tracker-miner-files.c
+++ b/src/miners/fs/tracker-miner-files.c
@@ -73,6 +73,7 @@ struct ProcessFileData {
 	TrackerSparqlBuilder *sparql;
 	GCancellable *cancellable;
 	GFile *file;
+	GFileInfo *file_info;
 };
 
 typedef void (*fast_async_cb) (const gchar *preupdate,
@@ -1945,6 +1946,9 @@ process_file_data_free (ProcessFileData *data)
 	g_object_unref (data->sparql);
 	g_object_unref (data->cancellable);
 	g_object_unref (data->file);
+	if (data->file_info) {
+		g_object_unref (data->file_info);
+	}
 	g_slice_free (ProcessFileData, data);
 }
 
@@ -1957,6 +1961,8 @@ extractor_get_embedded_metadata_cb (const gchar *preupdate,
 {
 	ProcessFileData *data = user_data;
 	const gchar *uuid;
+	gboolean is_iri;
+	const gchar *urn;
 
 	if (error) {
 		tracker_sparql_builder_graph_close (data->sparql);
@@ -1968,12 +1974,21 @@ extractor_get_embedded_metadata_cb (const gchar *preupdate,
 		return;
 	}
 
-	if (sparql && *sparql) {
-		gboolean is_iri;
-		const gchar *urn;
+	urn = miner_files_get_file_urn (data->miner, data->file, &is_iri);
 
-		urn = miner_files_get_file_urn (data->miner, data->file, &is_iri);
+	/* Laying the link between the IE and the DO. We use IE = DO, don't do this
+	 * in case of error so that we can distinguish between succeeded and failed
+	 * files with sparql queries */
+	tracker_sparql_builder_predicate (data->sparql, "a");
+	tracker_sparql_builder_object (data->sparql, "nie:InformationElement");
+	tracker_sparql_builder_predicate (data->sparql, "nie:isStoredAs");
+	if (is_iri) {
+		tracker_sparql_builder_object_iri (data->sparql, urn);
+	} else {
+		tracker_sparql_builder_object (data->sparql, urn);
+	}
 
+	if (sparql && *sparql) {
 		if (is_iri) {
 			gchar *str;
 
@@ -2418,6 +2433,8 @@ process_file_cb (GObject      *object,
 	mime_type = g_file_info_get_content_type (file_info);
 	urn = miner_files_get_file_urn (TRACKER_MINER_FILES (data->miner), file, &is_iri);
 
+	data->file_info = file_info; /* ownership transfer */
+
 	tracker_sparql_builder_insert_silent_open (sparql, NULL);
 	tracker_sparql_builder_graph_open (sparql, TRACKER_MINER_FS_GRAPH_URN);
 
@@ -2429,7 +2446,6 @@ process_file_cb (GObject      *object,
 
 	tracker_sparql_builder_predicate (sparql, "a");
 	tracker_sparql_builder_object (sparql, "nfo:FileDataObject");
-	tracker_sparql_builder_object (sparql, "nie:InformationElement");
 
 	is_directory = (g_file_info_get_file_type (file_info) == G_FILE_TYPE_DIRECTORY ?
 	                TRUE : FALSE);
@@ -2458,14 +2474,6 @@ process_file_cb (GObject      *object,
 	tracker_sparql_builder_predicate (sparql, "nfo:fileLastAccessed");
 	tracker_sparql_builder_object_date (sparql, (time_t *) &time_);
 
-	/* Laying the link between the IE and the DO. We use IE = DO */
-	tracker_sparql_builder_predicate (sparql, "nie:isStoredAs");
-	if (is_iri) {
-		tracker_sparql_builder_object_iri (sparql, urn);
-	} else {
-		tracker_sparql_builder_object (sparql, urn);
-	}
-
 	/* The URL of the DataObject (because IE = DO, this is correct) */
 	tracker_sparql_builder_predicate (sparql, "nie:url");
 	tracker_sparql_builder_object_string (sparql, uri);
@@ -2485,7 +2493,6 @@ process_file_cb (GObject      *object,
 		g_idle_add (extractor_skip_embedded_metadata_idle, data);
 	}
 
-	g_object_unref (file_info);
 	g_free (uri);
 }
 



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