Commit 316abf1c authored by Carlos Garnacho's avatar Carlos Garnacho

tracker-miner-fs: Use TrackerResource for attribute updates

This drops the last usage of TrackerSparqlBuilder in tracker-miner-fs
parent 9ab886dd
...@@ -63,7 +63,6 @@ typedef struct ProcessFileData ProcessFileData; ...@@ -63,7 +63,6 @@ typedef struct ProcessFileData ProcessFileData;
struct ProcessFileData { struct ProcessFileData {
TrackerMinerFiles *miner; TrackerMinerFiles *miner;
TrackerSparqlBuilder *sparql;
GCancellable *cancellable; GCancellable *cancellable;
GFile *file; GFile *file;
gchar *mime_type; gchar *mime_type;
...@@ -2255,7 +2254,6 @@ static void ...@@ -2255,7 +2254,6 @@ static void
process_file_data_free (ProcessFileData *data) process_file_data_free (ProcessFileData *data)
{ {
g_object_unref (data->miner); g_object_unref (data->miner);
g_object_unref (data->sparql);
g_object_unref (data->cancellable); g_object_unref (data->cancellable);
g_object_unref (data->file); g_object_unref (data->file);
g_object_unref (data->task); g_object_unref (data->task);
...@@ -2463,7 +2461,6 @@ miner_files_process_file (TrackerMinerFS *fs, ...@@ -2463,7 +2461,6 @@ miner_files_process_file (TrackerMinerFS *fs,
data = g_slice_new0 (ProcessFileData); data = g_slice_new0 (ProcessFileData);
data->miner = g_object_ref (fs); data->miner = g_object_ref (fs);
data->cancellable = g_object_ref (g_task_get_cancellable (task)); data->cancellable = g_object_ref (g_task_get_cancellable (task));
data->sparql = tracker_sparql_builder_new_update ();
data->file = g_object_ref (file); data->file = g_object_ref (file);
data->task = g_object_ref (task); data->task = g_object_ref (task);
...@@ -2493,19 +2490,18 @@ process_file_attributes_cb (GObject *object, ...@@ -2493,19 +2490,18 @@ process_file_attributes_cb (GObject *object,
GAsyncResult *result, GAsyncResult *result,
gpointer user_data) gpointer user_data)
{ {
TrackerSparqlBuilder *sparql; TrackerResource *resource;
ProcessFileData *data; ProcessFileData *data;
const gchar *urn; const gchar *urn;
GFileInfo *file_info; GFileInfo *file_info;
guint64 time_; guint64 time_;
GFile *file; GFile *file;
gchar *uri; gchar *uri, *time_str, *sparql_str;
GError *error = NULL; GError *error = NULL;
gboolean is_iri; gboolean is_iri;
data = user_data; data = user_data;
file = G_FILE (object); file = G_FILE (object);
sparql = data->sparql;
file_info = g_file_query_info_finish (file, result, &error); file_info = g_file_query_info_finish (file, result, &error);
if (error) { if (error) {
...@@ -2529,55 +2525,31 @@ process_file_attributes_cb (GObject *object, ...@@ -2529,55 +2525,31 @@ process_file_attributes_cb (GObject *object,
return; return;
} }
resource = tracker_resource_new (urn);
/* Update nfo:fileLastModified */ /* Update nfo:fileLastModified */
tracker_sparql_builder_delete_open (sparql, NULL);
tracker_sparql_builder_subject_iri (sparql, urn);
tracker_sparql_builder_predicate (sparql, "nfo:fileLastModified");
tracker_sparql_builder_object_variable (sparql, "lastmodified");
tracker_sparql_builder_delete_close (sparql);
tracker_sparql_builder_where_open (sparql);
tracker_sparql_builder_subject_iri (sparql, urn);
tracker_sparql_builder_predicate (sparql, "nfo:fileLastModified");
tracker_sparql_builder_object_variable (sparql, "lastmodified");
tracker_sparql_builder_where_close (sparql);
tracker_sparql_builder_insert_open (sparql, NULL);
tracker_sparql_builder_graph_open (sparql, TRACKER_OWN_GRAPH_URN);
tracker_sparql_builder_subject_iri (sparql, urn);
time_ = g_file_info_get_attribute_uint64 (file_info, G_FILE_ATTRIBUTE_TIME_MODIFIED); time_ = g_file_info_get_attribute_uint64 (file_info, G_FILE_ATTRIBUTE_TIME_MODIFIED);
tracker_sparql_builder_predicate (sparql, "nfo:fileLastModified"); time_str = tracker_date_to_string (time_);
tracker_sparql_builder_object_date (sparql, (time_t *) &time_); tracker_resource_set_string (resource, "nfo:fileLastModified", time_str);
tracker_sparql_builder_graph_close (sparql); g_free (time_str);
tracker_sparql_builder_insert_close (sparql);
/* Update nfo:fileLastAccessed */ /* Update nfo:fileLastAccessed */
tracker_sparql_builder_delete_open (sparql, NULL);
tracker_sparql_builder_subject_iri (sparql, urn);
tracker_sparql_builder_predicate (sparql, "nfo:fileLastAccessed");
tracker_sparql_builder_object_variable (sparql, "lastaccessed");
tracker_sparql_builder_delete_close (sparql);
tracker_sparql_builder_where_open (sparql);
tracker_sparql_builder_subject_iri (sparql, urn);
tracker_sparql_builder_predicate (sparql, "nfo:fileLastAccessed");
tracker_sparql_builder_object_variable (sparql, "lastaccessed");
tracker_sparql_builder_where_close (sparql);
tracker_sparql_builder_insert_open (sparql, NULL);
tracker_sparql_builder_graph_open (sparql, TRACKER_OWN_GRAPH_URN);
tracker_sparql_builder_subject_iri (sparql, urn);
time_ = g_file_info_get_attribute_uint64 (file_info, G_FILE_ATTRIBUTE_TIME_ACCESS); time_ = g_file_info_get_attribute_uint64 (file_info, G_FILE_ATTRIBUTE_TIME_ACCESS);
tracker_sparql_builder_predicate (sparql, "nfo:fileLastAccessed"); time_str = tracker_date_to_string (time_);
tracker_sparql_builder_object_date (sparql, (time_t *) &time_); tracker_resource_set_string (resource, "nfo:fileLastAccessed", time_str);
tracker_sparql_builder_graph_close (sparql); g_free (time_str);
tracker_sparql_builder_insert_close (sparql);
g_object_unref (file_info); g_object_unref (file_info);
g_free (uri); g_free (uri);
/* Notify about the success */ /* Notify about the success */
sparql_str = tracker_resource_print_sparql_update (resource, NULL, TRACKER_OWN_GRAPH_URN);
tracker_miner_fs_notify_finish (TRACKER_MINER_FS (data->miner), data->task, tracker_miner_fs_notify_finish (TRACKER_MINER_FS (data->miner), data->task,
tracker_sparql_builder_get_result (sparql), sparql_str, NULL);
NULL);
process_file_data_free (data); process_file_data_free (data);
g_object_unref (resource);
g_free (sparql_str);
} }
static gboolean static gboolean
...@@ -2591,7 +2563,6 @@ miner_files_process_file_attributes (TrackerMinerFS *fs, ...@@ -2591,7 +2563,6 @@ miner_files_process_file_attributes (TrackerMinerFS *fs,
data = g_slice_new0 (ProcessFileData); data = g_slice_new0 (ProcessFileData);
data->miner = g_object_ref (fs); data->miner = g_object_ref (fs);
data->cancellable = g_object_ref (g_task_get_cancellable (task)); data->cancellable = g_object_ref (g_task_get_cancellable (task));
data->sparql = tracker_sparql_builder_new_update ();
data->file = g_object_ref (file); data->file = g_object_ref (file);
data->task = g_object_ref (task); data->task = g_object_ref (task);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment