[tracker/on-extractor-error: 3/3] miners/fs: Don't set IE properties in case of error
- From: Philip Van Hoof <pvanhoof src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/on-extractor-error: 3/3] miners/fs: Don't set IE properties in case of error
- Date: Tue, 3 May 2011 15:33:30 +0000 (UTC)
commit 1331dccbc651843c0afb4571d0bb59e69ffac7fe
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 | 41 ++++++++++++++++++++--------------
1 files changed, 24 insertions(+), 17 deletions(-)
---
diff --git a/src/miners/fs/tracker-miner-files.c b/src/miners/fs/tracker-miner-files.c
index d465ee2..76b2a87 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, *mime_type;
if (error) {
tracker_sparql_builder_graph_close (data->sparql);
@@ -1968,12 +1974,24 @@ 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);
+ mime_type = g_file_info_get_content_type (data->file_info);
- 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);
+ }
+ tracker_sparql_builder_predicate (data->sparql, "nie:mimeType");
+ tracker_sparql_builder_object_string (data->sparql, mime_type);
+ if (sparql && *sparql) {
if (is_iri) {
gchar *str;
@@ -2418,6 +2436,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 +2449,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,21 +2477,10 @@ 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);
- tracker_sparql_builder_predicate (sparql, "nie:mimeType");
- tracker_sparql_builder_object_string (sparql, mime_type);
-
miner_files_add_to_datasource (data->miner, file, sparql);
if (tracker_extract_module_manager_mimetype_is_handled (mime_type)) {
@@ -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]