tracker r3131 - in trunk: . src/libtracker-data
- From: carlosg svn gnome org
- To: svn-commits-list gnome org
- Subject: tracker r3131 - in trunk: . src/libtracker-data
- Date: Wed, 25 Mar 2009 10:34:32 +0000 (UTC)
Author: carlosg
Date: Wed Mar 25 10:34:32 2009
New Revision: 3131
URL: http://svn.gnome.org/viewvc/tracker?rev=3131&view=rev
Log:
2009-03-25 Carlos Garnacho <carlos imendio com>
* src/libtracker-data/tracker-data-update.c
(tracker_data_update_replace_service): Refactored not to have
duplicated code, do not compare file mtimes with the Accessed column in
the Services table, instead use the GetServiceID stored procedure
and compare against the IndexTime column.
Modified:
trunk/ChangeLog
trunk/src/libtracker-data/tracker-data-update.c
Modified: trunk/src/libtracker-data/tracker-data-update.c
==============================================================================
--- trunk/src/libtracker-data/tracker-data-update.c (original)
+++ trunk/src/libtracker-data/tracker-data-update.c Wed Mar 25 10:34:32 2009
@@ -678,11 +678,13 @@
TrackerDBInterface *iface;
TrackerDBResultSet *result_set;
const gchar *modified;
- GError *error = NULL;
TrackerService *service;
gchar *escaped_path;
gchar *dirname;
gchar *basename;
+ time_t file_mtime;
+ gboolean set_metadata = FALSE;
+ guint32 id = 0;
g_return_if_fail (path != NULL);
g_return_if_fail (metadata != NULL);
@@ -713,81 +715,56 @@
return;
}
+ file_mtime = atoi (modified);
escaped_path = tracker_escape_string (path);
basename = g_path_get_basename (escaped_path);
dirname = g_path_get_dirname (escaped_path);
- /* TODO Warning: comparing Modified against Accessed. Do we have a
- * better field for this? */
-
- result_set = tracker_db_interface_execute_query (iface, &error,
- "SELECT ID, Accessed < '%s' FROM Services "
- "WHERE Path = '%s' AND "
- "Name = '%s'",
- modified,
- dirname, basename);
-
- if (error) {
- g_error_free (error);
- }
-
+ result_set = tracker_db_interface_execute_procedure (iface, NULL,
+ "GetServiceID",
+ dirname,
+ basename,
+ NULL);
if (result_set) {
- GValue id_value = { 0, };
- GValue is_value = { 0, };
- gint iid_value, iis_value;
-
- _tracker_db_result_set_get_value (result_set, 0, &id_value);
- iid_value = g_value_get_int (&id_value);
-
- _tracker_db_result_set_get_value (result_set, 1, &is_value);
- iis_value = g_value_get_int (&is_value);
-
- if (iis_value) {
- ForeachInMetadataInfo *info;
+ guint mtime;
- info = g_slice_new (ForeachInMetadataInfo);
- info->service = service;
- info->iid_value = iid_value;
+ tracker_db_result_set_get (result_set,
+ 0, &id,
+ 1, &mtime,
+ -1);
- info->config = tracker_data_manager_get_config ();
- info->language = tracker_data_manager_get_language ();
-
- g_hash_table_foreach (metadata,
- foreach_in_metadata_set_metadata,
- info);
-
- g_slice_free (ForeachInMetadataInfo, info);
+ if (mtime != file_mtime) {
+ set_metadata = TRUE;
}
- g_value_unset (&id_value);
- g_value_unset (&is_value);
-
g_object_unref (result_set);
} else {
- guint32 id;
-
id = tracker_data_update_get_new_service_id (iface);
if (tracker_data_update_create_service (service, id,
dirname, basename,
metadata)) {
- ForeachInMetadataInfo *info;
+ set_metadata = TRUE;
+ }
+ }
- info = g_slice_new (ForeachInMetadataInfo);
+ if (set_metadata) {
+ ForeachInMetadataInfo *info;
- info->service = service;
- info->iid_value = id;
+ info = g_slice_new (ForeachInMetadataInfo);
- info->config = tracker_data_manager_get_config ();
- info->language = tracker_data_manager_get_language ();
+ info->service = service;
+ info->iid_value = id;
- g_hash_table_foreach (metadata,
- foreach_in_metadata_set_metadata,
- info);
+ info->config = tracker_data_manager_get_config ();
+ info->language = tracker_data_manager_get_language ();
- g_slice_free (ForeachInMetadataInfo, info);
- }
+ g_hash_table_foreach (metadata,
+ foreach_in_metadata_set_metadata,
+ info);
+
+ g_slice_free (ForeachInMetadataInfo, info);
}
g_free (dirname);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]