tracker r1509 - in branches/indexer-split: . src/tracker-indexer src/trackerd
- From: mr svn gnome org
- To: svn-commits-list gnome org
- Subject: tracker r1509 - in branches/indexer-split: . src/tracker-indexer src/trackerd
- Date: Wed, 28 May 2008 10:28:45 +0000 (UTC)
Author: mr
Date: Wed May 28 10:28:45 2008
New Revision: 1509
URL: http://svn.gnome.org/viewvc/tracker?rev=1509&view=rev
Log:
* src/tracker-indexer/Makefile.am:
* src/tracker-indexer/tracker-metadata.[ch]:
* src/trackerd/Makefile.am:
* src/trackerd/tracker-db-sqlite.c:
* src/trackerd/tracker-db.h:
* src/trackerd/tracker-dbus-files.c: Moved the
tracker-metadata.[ch] to the tracker-indexer directory, this also
is a transitional state for some of this code. Some of the code
from tracker-db.c has been commented out with #if 0 since it is
being moved to the indexer at some point. All of this code is
marked with the comment FIXME-indexer-split.
Added:
branches/indexer-split/src/tracker-indexer/tracker-metadata.c
- copied, changed from r1500, /branches/indexer-split/src/trackerd/tracker-metadata.c
branches/indexer-split/src/tracker-indexer/tracker-metadata.h
- copied, changed from r1500, /branches/indexer-split/src/trackerd/tracker-metadata.h
Removed:
branches/indexer-split/src/trackerd/tracker-metadata.c
branches/indexer-split/src/trackerd/tracker-metadata.h
Modified:
branches/indexer-split/ChangeLog
branches/indexer-split/src/tracker-indexer/Makefile.am
branches/indexer-split/src/trackerd/Makefile.am
branches/indexer-split/src/trackerd/tracker-db-sqlite.c
branches/indexer-split/src/trackerd/tracker-db.c
branches/indexer-split/src/trackerd/tracker-db.h
branches/indexer-split/src/trackerd/tracker-dbus-files.c
Modified: branches/indexer-split/src/tracker-indexer/Makefile.am
==============================================================================
--- branches/indexer-split/src/tracker-indexer/Makefile.am (original)
+++ branches/indexer-split/src/tracker-indexer/Makefile.am Wed May 28 10:28:45 2008
@@ -19,7 +19,9 @@
tracker-indexer.c \
tracker-indexer.h \
tracker-indexer-module.c \
- tracker-indexer-module.h
+ tracker-indexer-module.h \
+ tracker-metadata.c \
+ tracker-metadata.h
tracker_indexer_LDADD = \
$(GLIB2_LIBS) \
Copied: branches/indexer-split/src/tracker-indexer/tracker-metadata.c (from r1500, /branches/indexer-split/src/trackerd/tracker-metadata.c)
==============================================================================
--- /branches/indexer-split/src/trackerd/tracker-metadata.c (original)
+++ branches/indexer-split/src/tracker-indexer/tracker-metadata.c Wed May 28 10:28:45 2008
@@ -35,52 +35,65 @@
#include <libtracker-common/tracker-file-utils.h>
#include <libtracker-common/tracker-ontology.h>
#include <libtracker-common/tracker-os-dependant.h>
+#include <libtracker-common/tracker-utils.h>
#include "tracker-metadata.h"
-#include "tracker-utils.h"
-#include "tracker-main.h"
-char *
-tracker_metadata_get_text_file (const char *uri, const char *mime)
+gchar *
+tracker_metadata_get_text_file (const gchar *uri,
+ const gchar *mime)
{
- char *text_filter_file;
- char *service_type;
- text_filter_file = NULL;
+ gchar *text_filter_file = NULL;
+ gchar *service_type;
- /* no need to filter text based files - index em directly */
+ /* No need to filter text based files - index them directly */
service_type = tracker_ontology_get_service_type_for_mime (mime);
- if ( !strcmp ("Text", service_type) || !strcmp ("Development", service_type)) {
+ if (!strcmp (service_type, "Text") ||
+ !strcmp (service_type, "Development")) {
g_free (service_type);
- return g_filename_from_utf8 (uri, -1, NULL, NULL, NULL);
+ return g_filename_from_utf8 (uri, -1, NULL, NULL, NULL);
} else {
- char *tmp;
-
- tmp = g_strdup (LIBDIR "/tracker/filters/");
-
+ gchar *text_filter_file;
+ gchar *str;
+
#ifdef OS_WIN32
- text_filter_file = g_strconcat (tmp, mime, "_filter.bat", NULL);
+ str = g_strconcat (mime, "_filter.bat", NULL);
#else
- text_filter_file = g_strconcat (tmp, mime, "_filter", NULL);
+ str = g_strconcat (mime, "_filter", NULL);
#endif
-
- g_free (tmp);
+
+ text_filter_file = g_build_filename (LIBDIR,
+ "tracker",
+ "filters",
+ str,
+ NULL);
+ g_free (str);
}
- if (text_filter_file && g_file_test (text_filter_file, G_FILE_TEST_EXISTS)) {
- char *argv[4];
- char *temp_file_name;
- int fd;
+ if (text_filter_file &&
+ g_file_test (text_filter_file, G_FILE_TEST_EXISTS)) {
+ gchar *argv[4];
+ gchar *filename;
+ gchar *sys_tmp_dir;
+ gchar *temp_filename;
+ gint fd;
+
+ filename = g_strdup_printf ("Tracker-%s.%d", g_get_user_name (), getpid ());
+ sys_tmp_dir = g_build_filename (g_get_tmp_dir (), filename, NULL);
+ g_free (filename);
+
+ temp_filename = g_build_filename (sys_tmp_dir,
+ "tmp_text_file_XXXXXX",
+ NULL);
+ g_free (sys_tmp_dir);
- temp_file_name = g_build_filename (tracker_get_sys_tmp_dir (),
- "tmp_text_file_XXXXXX",
- NULL);
-
- fd = g_mkstemp (temp_file_name);
+ fd = g_mkstemp (temp_filename);
if (fd == -1) {
- g_warning ("make tmp file %s failed", temp_file_name);
+ g_warning ("Could not open a temporary file:'%s'", temp_filename);
+ g_free (temp_filename);
return NULL;
} else {
close (fd);
@@ -88,7 +101,7 @@
argv[0] = g_strdup (text_filter_file);
argv[1] = g_filename_from_utf8 (uri, -1, NULL, NULL, NULL);
- argv[2] = g_strdup (temp_file_name);
+ argv[2] = g_strdup (temp_filename);
argv[3] = NULL;
g_free (text_filter_file);
@@ -104,21 +117,18 @@
argv[1], argv[0]);
if (tracker_spawn (argv, 30, NULL, NULL)) {
-
-
g_free (argv[0]);
g_free (argv[1]);
g_free (argv[2]);
- if (tracker_file_is_valid (temp_file_name)) {
- return temp_file_name;
+ if (tracker_file_is_valid (temp_filename)) {
+ return temp_filename;
} else {
- g_free (temp_file_name);
+ g_free (temp_filename);
return NULL;
}
-
} else {
- g_free (temp_file_name);
+ g_free (temp_filename);
g_free (argv[0]);
g_free (argv[1]);
@@ -126,7 +136,6 @@
return NULL;
}
-
} else {
g_free (text_filter_file);
}
@@ -134,13 +143,14 @@
return NULL;
}
-
-char *
-tracker_metadata_get_thumbnail (const char *path, const char *mime, const char *size)
+gchar *
+tracker_metadata_get_thumbnail (const gchar *path,
+ const gchar *mime,
+ const gchar *size)
{
- gchar *thumbnail;
- gchar *argv[5];
- gint exit_status;
+ gchar *thumbnail;
+ gchar *argv[5];
+ gint exit_status;
argv[0] = g_strdup ("tracker-thumbnailer");
argv[1] = g_filename_from_utf8 (path, -1, NULL, NULL, NULL);
@@ -153,7 +163,11 @@
} else if (exit_status != EXIT_SUCCESS) {
thumbnail = NULL;
} else {
- g_message ("got thumbnail %s", thumbnail);
+ g_message ("Managed to get thumbnail:'%s' for:'%s' with mime:'%s' and size:'%s'",
+ thumbnail,
+ argv[1],
+ argv[2],
+ argv[3]);
}
g_free (argv[0]);
@@ -165,14 +179,16 @@
}
void
-tracker_metadata_get_embedded (const char *uri, const char *mime, GHashTable *table)
+tracker_metadata_get_embedded (const gchar *uri,
+ const gchar *mime,
+ GHashTable *table)
{
- gboolean success;
- char *argv[4];
- char *output;
- char **values;
- char *service_type;
- gint i;
+ gboolean success;
+ gchar *argv[4];
+ gchar *output;
+ gchar **values;
+ gchar *service_type;
+ gint i;
if (!uri || !mime || !table) {
return;
@@ -188,19 +204,27 @@
return;
}
- /* we extract metadata out of process using pipes */
+ /* We extract metadata out of process using pipes */
argv[0] = g_strdup ("tracker-extract");
argv[1] = g_filename_from_utf8 (uri, -1, NULL, NULL, NULL);
argv[2] = g_locale_from_utf8 (mime, -1, NULL, NULL, NULL);
argv[3] = NULL;
- if (!argv[1] || !argv[2]) {
- g_critical ("uri or mime could not be converted to locale format");
+ if (!argv[1]) {
+ g_critical ("Could not create UTF-8 uri from:'%s'", uri);
g_free (argv[0]);
g_free (argv[1]);
g_free (argv[2]);
+ return;
+ }
+ if (!argv[2]) {
+ g_critical ("Could not create UTF-8 mime from:'%s'", mime);
+
+ g_free (argv[0]);
+ g_free (argv[1]);
+ g_free (argv[2]);
return;
}
@@ -210,36 +234,41 @@
g_free (argv[1]);
g_free (argv[2]);
- if (!success || !output)
+ if (!success || !output) {
return;
+ }
- /* parse returned stdout and extract keys and associated metadata values */
-
+ /* Parse returned stdout and extract keys and associated
+ * metadata values
+ */
values = g_strsplit_set (output, ";", -1);
for (i = 0; values[i]; i++) {
- char *meta_data, *sep;
- const char *name, *value;
- char *utf_value;
+ const gchar *name, *value;
+ gchar *meta_data, *sep;
+ gchar *utf_value;
meta_data = g_strstrip (values[i]);
sep = strchr (meta_data, '=');
- if (!sep)
+ if (!sep) {
continue;
+ }
- /* zero out the separator, so we get
- * NULL-terminated name and value
- */
+ /* Zero out the separator, so we get NULL-terminated
+ * name and value
+ */
sep[0] = '\0';
name = meta_data;
value = sep + 1;
- if (!name || !value)
+ if (!name || !value) {
continue;
+ }
- if (g_hash_table_lookup (table, name))
+ if (g_hash_table_lookup (table, name)) {
continue;
+ }
if (!g_utf8_validate (value, -1, NULL)) {
utf_value = g_locale_to_utf8 (value, -1, NULL, NULL, NULL);
@@ -247,10 +276,28 @@
utf_value = g_strdup (value);
}
- if (!utf_value)
- continue;
-
- tracker_add_metadata_to_table (table, g_strdup (name), utf_value);
+ if (!utf_value) {
+ GSList *list;
+ gchar *key;
+
+ key = g_strdup (name);
+
+ /* Code is taken from
+ * tracker_add_metadata_to_table() in
+ * trackerd/tracker-utils.c
+ *
+ * This was put directly in here because we
+ * need it for the tracker-indexer as part of
+ * the indexer-split move for
+ * tracker-metadata.[ch].
+ *
+ * -Martyn
+ */
+ list = g_hash_table_lookup (table, key);
+ list = g_slist_prepend (list, utf_value);
+ g_hash_table_steal (table, key);
+ g_hash_table_insert (table, key, list);
+ }
}
g_strfreev (values);
Copied: branches/indexer-split/src/tracker-indexer/tracker-metadata.h (from r1500, /branches/indexer-split/src/trackerd/tracker-metadata.h)
==============================================================================
--- /branches/indexer-split/src/trackerd/tracker-metadata.h (original)
+++ branches/indexer-split/src/tracker-indexer/tracker-metadata.h Wed May 28 10:28:45 2008
@@ -18,8 +18,8 @@
* Boston, MA 02110-1301, USA.
*/
-#ifndef __TRACKERD_METADATA_H__
-#define __TRACKERD_METADATA_H__
+#ifndef __TRACKER_METADATA_H__
+#define __TRACKER_METADATA_H__
#include <glib.h>
@@ -28,18 +28,15 @@
G_BEGIN_DECLS
-void tracker_metadata_get_embedded (const char *uri,
- const char *mime,
- GHashTable *table);
-char *tracker_metadata_get_text_file (const char *uri,
- const char *mime);
-void tracker_metadata_parse_text_contents (const char *file_as_text,
- unsigned int ID);
-char *tracker_metadata_get_thumbnail (const char *path,
- const char *mime,
- const char *size);
-char *tracker_get_service_type_for_mime (const char *mime);
+gchar *tracker_metadata_get_text_file (const gchar *uri,
+ const gchar *mime);
+gchar *tracker_metadata_get_thumbnail (const gchar *path,
+ const gchar *mime,
+ const gchar *size);
+void tracker_metadata_get_embedded (const gchar *uri,
+ const gchar *mime,
+ GHashTable *table);
G_END_DECLS
-#endif /* __TRACKERD_METADATA_H__*/
+#endif /* __TRACKER_METADATA_H__*/
Modified: branches/indexer-split/src/trackerd/Makefile.am
==============================================================================
--- branches/indexer-split/src/trackerd/Makefile.am (original)
+++ branches/indexer-split/src/trackerd/Makefile.am Wed May 28 10:28:45 2008
@@ -99,8 +99,6 @@
tracker-main.c \
tracker-main.h \
tracker-marshal-main.c \
- tracker-metadata.c \
- tracker-metadata.h \
tracker-process-files.c \
tracker-process-files.h \
tracker-query-tree.c \
Modified: branches/indexer-split/src/trackerd/tracker-db-sqlite.c
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-db-sqlite.c (original)
+++ branches/indexer-split/src/trackerd/tracker-db-sqlite.c Wed May 28 10:28:45 2008
@@ -42,7 +42,6 @@
#include "tracker-db-sqlite.h"
#include "tracker-indexer.h"
#include "tracker-cache.h"
-#include "tracker-metadata.h"
#include "tracker-main.h"
#include "tracker-utils.h"
#include "tracker-watch.h"
@@ -1553,13 +1552,6 @@
return !tracker_db_manager_file_exists (TRACKER_DB_COMMON);
}
-static gint
-tracker_metadata_is_key (const gchar *service, const gchar *meta_name)
-{
- return tracker_ontology_metadata_key_in_service (service, meta_name);
-}
-
-
static inline gboolean
is_equal (const char *s1, const char *s2)
{
@@ -1567,10 +1559,13 @@
}
/* Replace with tracker_ontology_get_field_column_in_services */
-char *
-tracker_db_get_field_name (const char *service, const char *meta_name)
+gchar *
+tracker_db_get_field_name (const gchar *service,
+ const gchar *meta_name)
{
- int key_field = tracker_metadata_is_key (service, meta_name);
+ gint key_field;
+
+ key_field = tracker_ontology_metadata_key_in_service (service, meta_name);
if (key_field > 0) {
return g_strdup_printf ("KeyMetadata%d", key_field);
@@ -3058,12 +3053,20 @@
}
void
-tracker_db_delete_metadata_value (DBConnection *db_con, const char *service, const char *id, const char *key, const char *value)
+tracker_db_delete_metadata_value (DBConnection *db_con,
+ const gchar *service,
+ const gchar *id,
+ const gchar *key,
+ const gchar *value)
{
- char *old_value = NULL, *new_value = NULL, *mvalue;
TrackerField *def;
+ gchar *old_value = NULL;
+ gchar *new_value = NULL;
+ gchar *mvalue;
+ gchar *res_service;
gboolean update_index;
+ gint key_field;
g_return_if_fail (id && key && service && db_con);
@@ -3074,29 +3077,26 @@
return;
}
-
if (!tracker_field_get_embedded (def) &&
tracker_ontology_service_type_has_embedded (service)) {
backup_delete_non_embedded_metadata_value (db_con, id, tracker_field_get_id (def), value);
}
-
- char *res_service = tracker_db_get_service_for_entity (db_con, id);
+ res_service = tracker_db_get_service_for_entity (db_con, id);
if (!res_service) {
g_warning ("Entity not found");
return;
}
- int key_field = tracker_metadata_is_key (res_service, key);
-
- update_index = (tracker_field_get_data_type (def) == TRACKER_FIELD_TYPE_INDEX
- || tracker_field_get_data_type (def) == TRACKER_FIELD_TYPE_KEYWORD);
+ key_field = tracker_ontology_metadata_key_in_service (res_service, key);
+ update_index =
+ tracker_field_get_data_type (def) == TRACKER_FIELD_TYPE_INDEX ||
+ tracker_field_get_data_type (def) == TRACKER_FIELD_TYPE_KEYWORD;
+
if (update_index) {
-
- /* get current value and claculate the new value */
-
+ /* Get current value and claculate the new value */
old_value = tracker_db_get_metadata_delimited (db_con, service, id, key);
if (old_value) {
@@ -3105,11 +3105,9 @@
g_free (res_service);
return;
}
-
}
-
- /* perform deletion */
+ /* Perform deletion */
switch (tracker_field_get_data_type (def)) {
case TRACKER_FIELD_TYPE_INDEX:
@@ -3133,13 +3131,11 @@
case TRACKER_FIELD_TYPE_INTEGER:
case TRACKER_FIELD_TYPE_DATE:
-
tracker_exec_proc (db_con, "DeleteMetadataNumericValue", id, tracker_field_get_id (def), value, NULL);
break;
case TRACKER_FIELD_TYPE_KEYWORD:
-
tracker_exec_proc (db_con, "DeleteMetadataKeywordValue", id, tracker_field_get_id (def), value, NULL);
break;
@@ -3149,13 +3145,11 @@
tracker_field_get_data_type (def),
key);
break;
-
-
}
if (key_field > 0) {
TrackerDBResultSet *result_set;
- gchar *value;
+ gchar *value;
result_set = tracker_db_get_metadata (db_con, service, id, key);
@@ -3163,7 +3157,9 @@
tracker_db_result_set_get (result_set, 0, &value, -1);
if (value) {
- char *esc_value = tracker_escape_string (value);
+ gchar *esc_value;
+
+ esc_value = tracker_escape_string (value);
tracker_db_exec_no_reply (db_con->db,
"update Services set KeyMetadata%d = '%s' where id = %s",
@@ -3185,8 +3181,7 @@
}
}
-
- /* update fulltext index differentially with old and new values */
+ /* Update fulltext index differentially with old and new values */
if (update_index) {
update_metadata_index (id, service, def, old_value, new_value);
}
@@ -3195,21 +3190,24 @@
g_free (old_value);
g_free (res_service);
-
}
-
void
-tracker_db_delete_metadata (DBConnection *db_con, const char *service, const char *id, const char *key, gboolean update_indexes)
+tracker_db_delete_metadata (DBConnection *db_con,
+ const gchar *service,
+ const gchar *id,
+ const gchar *key,
+ gboolean update_indexes)
{
- char *old_value = NULL;
- TrackerField *def;
- gboolean update_index;
+ TrackerField *def;
+ gchar *old_value = NULL;
+ gchar *res_service;
+ gboolean update_index;
+ gint key_field;
g_return_if_fail (id && key && service && db_con);
-
- /* get type details */
+ /* Get type details */
def = tracker_ontology_get_field_def(key);
if (!def) {
@@ -3221,66 +3219,59 @@
backup_delete_non_embedded_metadata (db_con, id, tracker_field_get_id (def));
}
-
- char *res_service = tracker_db_get_service_for_entity (db_con, id);
+ res_service = tracker_db_get_service_for_entity (db_con, id);
if (!res_service) {
g_warning ("Entity not found");
return;
}
+ key_field = tracker_ontology_metadata_key_in_service (res_service, key);
- int key_field = tracker_metadata_is_key (res_service, key);
-
- update_index = update_indexes && (tracker_field_get_data_type (def) == TRACKER_FIELD_TYPE_INDEX || tracker_field_get_data_type (def) == TRACKER_FIELD_TYPE_KEYWORD);
-
+ update_index =
+ update_indexes &&
+ (tracker_field_get_data_type (def) == TRACKER_FIELD_TYPE_INDEX ||
+ tracker_field_get_data_type (def) == TRACKER_FIELD_TYPE_KEYWORD);
if (update_index) {
/* get current value */
old_value = tracker_db_get_metadata_delimited (db_con, service, id, key);
}
-
-
if (key_field > 0) {
tracker_db_exec_no_reply (db_con->db,
"update Services set KeyMetadata%d = NULL where id = %s",
key_field, id);
}
-
-
- /* perform deletion */
+
+ /* Perform deletion */
switch (tracker_field_get_data_type (def)) {
-
- case TRACKER_FIELD_TYPE_INDEX:
- case TRACKER_FIELD_TYPE_STRING:
- case TRACKER_FIELD_TYPE_DOUBLE:
- tracker_exec_proc (db_con, "DeleteMetadata", id, tracker_field_get_id (def), NULL);
- break;
-
- case TRACKER_FIELD_TYPE_INTEGER:
- case TRACKER_FIELD_TYPE_DATE:
- tracker_exec_proc (db_con, "DeleteMetadataNumeric", id, tracker_field_get_id (def), NULL);
- break;
-
+ case TRACKER_FIELD_TYPE_INDEX:
+ case TRACKER_FIELD_TYPE_STRING:
+ case TRACKER_FIELD_TYPE_DOUBLE:
+ tracker_exec_proc (db_con, "DeleteMetadata", id, tracker_field_get_id (def), NULL);
+ break;
- case TRACKER_FIELD_TYPE_KEYWORD:
- tracker_exec_proc (db_con, "DeleteMetadataKeyword", id, tracker_field_get_id (def), NULL);
- break;
-
- case TRACKER_FIELD_TYPE_FULLTEXT:
-
- tracker_exec_proc (db_con, "DeleteContent", id, tracker_field_get_id (def), NULL);
- break;
-
- default:
- g_warning ("Metadata could not be deleted as this "
- "operation is not supported by type:%d "
- "for metadata:'%s'",
- tracker_field_get_data_type (def),
- key);
- break;
-
+ case TRACKER_FIELD_TYPE_INTEGER:
+ case TRACKER_FIELD_TYPE_DATE:
+ tracker_exec_proc (db_con, "DeleteMetadataNumeric", id, tracker_field_get_id (def), NULL);
+ break;
+
+ case TRACKER_FIELD_TYPE_KEYWORD:
+ tracker_exec_proc (db_con, "DeleteMetadataKeyword", id, tracker_field_get_id (def), NULL);
+ break;
+
+ case TRACKER_FIELD_TYPE_FULLTEXT:
+ tracker_exec_proc (db_con, "DeleteContent", id, tracker_field_get_id (def), NULL);
+ break;
+
+ default:
+ g_warning ("Metadata could not be deleted as this "
+ "operation is not supported by type:%d "
+ "for metadata:'%s'",
+ tracker_field_get_data_type (def),
+ key);
+ break;
}
@@ -3288,12 +3279,9 @@
if (update_index && old_value) {
update_metadata_index (id, service, def, old_value, " ");
}
-
g_free (old_value);
g_free (res_service);
-
-
}
TrackerDBResultSet*
Modified: branches/indexer-split/src/trackerd/tracker-db.c
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-db.c (original)
+++ branches/indexer-split/src/trackerd/tracker-db.c Wed May 28 10:28:45 2008
@@ -35,7 +35,6 @@
#include "tracker-db.h"
#include "tracker-email.h"
-#include "tracker-metadata.h"
#include "tracker-process-files.h"
extern Tracker *tracker;
@@ -359,26 +358,6 @@
return (gchar **) g_ptr_array_free (array, FALSE);
}
-
-gboolean
-tracker_metadata_is_date (DBConnection *db_con, const char *meta)
-{
- TrackerField *def;
-
- def = tracker_ontology_get_field_def (meta);
-
- if (!def) {
- g_critical ("failed to get info for metadata type %s", meta);
- return FALSE;
- }
-
- /* FIXME: It is the same check again! */
- g_return_val_if_fail (def, FALSE);
-
- return tracker_field_get_data_type (def) == TRACKER_FIELD_TYPE_DATE;
-}
-
-
TrackerDBFileInfo *
tracker_db_get_pending_file (DBConnection *db_con, const char *uri)
{
@@ -844,14 +823,22 @@
void
-tracker_db_index_service (DBConnection *db_con, TrackerDBFileInfo *info, const char *service, GHashTable *meta_table, const char *attachment_uri, const char *attachment_service, gboolean get_embedded, gboolean get_full_text, gboolean get_thumbs)
-{
- char *str_file_id;
- const char *uri;
- GHashTable *index_table, *old_table;
+tracker_db_index_service (DBConnection *db_con,
+ TrackerDBFileInfo *info,
+ const gchar *service,
+ GHashTable *meta_table,
+ const gchar *attachment_uri,
+ const gchar *attachment_service,
+ gboolean get_embedded,
+ gboolean get_full_text,
+ gboolean get_thumbs)
+{
+ gchar *str_file_id;
+ const gchar *uri;
+ GHashTable *index_table, *old_table;
if (!service) {
- /* its an external service - TODO get external service name */
+ /* It's an external service - TODO get external service name */
if (service) {
g_message ("External service %s not supported yet", service);
} else {
@@ -893,8 +880,6 @@
uri, service);
}
-
-
if (!info->is_new) {
old_table = g_hash_table_new (g_str_hash, g_str_equal);
} else {
@@ -903,15 +888,26 @@
index_table = g_hash_table_new (g_str_hash, g_str_equal);
+#if 0
+ /* FIXME-indexer-split: This has been commented out as a
+ * result of moving tracker-metadata.[ch] to the indexer
+ * directory. This code will be removed when this function is
+ * updated to work correctly in the indexer application.
+ *
+ * -Martyn
+ */
+
/* get embedded metadata filter */
if (get_embedded && meta_table) {
tracker_metadata_get_embedded (info->uri, info->mime, meta_table);
}
+#endif
if (info->is_new) {
+ gchar *old_uri;
- char *old_uri = info->uri;
- info->uri = (char *) uri;
+ old_uri = info->uri;
+ info->uri = (gchar *) uri;
if (attachment_service) {
info->file_id = tracker_db_create_service (db_con, attachment_service, info);
@@ -934,12 +930,19 @@
str_file_id = tracker_uint_to_string (info->file_id);
if (get_thumbs && tracker_config_get_enable_thumbnails (tracker->config)) {
- char *small_thumb_file = NULL;
+#if 0
+ gchar *small_thumb_file = NULL;
+ /* FIXME-indexer-split: This has been commented out as a
+ * result of moving tracker-metadata.[ch] to the indexer
+ * directory. This code will be removed when this function is
+ * updated to work correctly in the indexer application.
+ *
+ * -Martyn
+ */
small_thumb_file = tracker_metadata_get_thumbnail (info->uri, info->mime, "normal");
-
g_free (small_thumb_file);
-
+#endif
}
@@ -950,13 +953,25 @@
if (get_full_text && tracker_config_get_enable_content_indexing (tracker->config)) {
- char *file_as_text;
+ gchar *file_as_text = NULL;
+#if 0
+ /* FIXME-indexer-split: This has been commented out as a
+ * result of moving tracker-metadata.[ch] to the indexer
+ * directory. This code will be removed when this function is
+ * updated to work correctly in the indexer application.
+ *
+ * -Martyn
+ */
file_as_text = tracker_metadata_get_text_file (info->uri, info->mime);
+#endif
if (file_as_text) {
-
- tracker_db_save_file_contents (db_con, index_table, old_table, file_as_text, info);
+ tracker_db_save_file_contents (db_con,
+ index_table,
+ old_table,
+ file_as_text,
+ info);
/* clear up if text contents are in a temp file */
if (g_str_has_prefix (file_as_text, tracker_get_sys_tmp_dir ())) {
@@ -964,45 +979,34 @@
}
g_free (file_as_text);
-
} else {
get_full_text = FALSE;
}
-
}
if (attachment_service) {
info->service_type_id = tracker_ontology_get_id_for_service_type (attachment_service);
}
- /* save stuff to Db */
-
-
-
+ /* Save stuff to Db */
if (!info->is_new) {
-
- /* update existing file entry */
+ /* Update existing file entry */
tracker_db_update_file (db_con, info);
- /* get original embedded metadata for the differential indexer */
+ /* Get original embedded metadata for the differential indexer */
old_table = tracker_db_get_indexable_content_words (db_con, info->file_id, old_table, TRUE);
- /* delete any exisitng embedded metadata */
+ /* Delete any exisitng embedded metadata */
tracker_exec_proc (db_con, "DeleteEmbeddedServiceMetadata1", str_file_id, NULL);
tracker_exec_proc (db_con, "DeleteEmbeddedServiceMetadata2", str_file_id, NULL);
tracker_exec_proc (db_con, "DeleteEmbeddedServiceMetadata3", str_file_id, NULL);
-
}
if (meta_table && (g_hash_table_size (meta_table) > 0)) {
tracker_db_save_metadata (db_con, meta_table, index_table, service, info->file_id, info->is_new);
}
-
-
-
-
- /* update full text indexes */
+ /* Update full text indexes */
if (info->is_new) {
tracker_db_update_indexes_for_new_service (info->file_id, info->service_type_id, index_table);
} else {
@@ -1012,19 +1016,19 @@
tracker_parser_text_free (index_table);
tracker_parser_text_free (old_table);
- /* check for backup user defined metadata */
+ /* Check for backup user defined metadata */
if (info->is_new) {
TrackerDBResultSet *result_set;
- char *name = tracker_file_get_vfs_name (info->uri);
- char *path = tracker_file_get_vfs_path (info->uri);
+ gchar *name = tracker_file_get_vfs_name (info->uri);
+ gchar *path = tracker_file_get_vfs_path (info->uri);
result_set = tracker_exec_proc (db_con->common, "GetBackupMetadata", path, name, NULL);
if (result_set) {
- gboolean valid = TRUE;
- GHashTable *meta_table;
- DatabaseAction db_action;
- gchar *key, *value;
+ gboolean valid = TRUE;
+ GHashTable *meta_table;
+ DatabaseAction db_action;
+ gchar *key, *value;
meta_table = g_hash_table_new_full (g_str_hash, g_str_equal,
(GDestroyNotify) g_free,
@@ -1062,7 +1066,6 @@
g_free (path);
}
-
g_free (str_file_id);
}
@@ -1109,16 +1112,23 @@
void
-tracker_db_index_file (DBConnection *db_con, TrackerDBFileInfo *info, const char *attachment_uri, const char *attachment_service)
-{
-
- GHashTable *meta_table;
- const char *ext;
- char *filename, *dirname;
- char *str_link_uri, *service_name;
- gboolean is_file_indexable, service_has_metadata, is_external_service, service_has_fulltext, service_has_thumbs, is_sidecar;
-
- const char *uri;
+tracker_db_index_file (DBConnection *db_con,
+ TrackerDBFileInfo *info,
+ const gchar *attachment_uri,
+ const gchar *attachment_service)
+{
+
+ GHashTable *meta_table;
+ const gchar *ext;
+ const gchar *uri;
+ gchar *filename, *dirname;
+ gchar *str_link_uri, *service_name;
+ gboolean is_file_indexable;
+ gboolean is_external_service;
+ gboolean is_sidecar;
+ gboolean service_has_metadata;
+ gboolean service_has_fulltext;
+ gboolean service_has_thumbs;
if (!attachment_uri) {
uri = info->uri;
@@ -1145,91 +1155,124 @@
info->mime, info->uri);
service_name = tracker_ontology_get_service_type_for_mime (info->mime);
-
}
if (info->is_link) {
- str_link_uri = g_build_filename (info->link_path, info->link_name, NULL);
+ str_link_uri = g_build_filename (info->link_path,
+ info->link_name,
+ NULL);
} else {
str_link_uri = NULL;
}
if (!info->is_hidden) {
-
- meta_table = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, (GDestroyNotify) free_metadata_list);
-
- tracker_add_metadata_to_table (meta_table, g_strdup ("File:NameDelimited"), g_strdup (uri));
+ meta_table = g_hash_table_new_full (g_str_hash,
+ g_str_equal,
+ g_free,
+ (GDestroyNotify) free_metadata_list);
+
+ tracker_add_metadata_to_table (meta_table,
+ g_strdup ("File:NameDelimited"),
+ g_strdup (uri));
dirname = g_path_get_dirname (uri);
filename = g_path_get_basename (uri);
ext = strrchr (filename, '.');
+
if (ext) {
ext++;
g_debug ("file extension is %s", ext);
- tracker_add_metadata_to_table (meta_table, g_strdup ("File:Ext"), g_strdup (ext));
+ tracker_add_metadata_to_table (meta_table,
+ g_strdup ("File:Ext"),
+ g_strdup (ext));
is_sidecar = strcmp("xmp",ext) == 0;
} else {
is_sidecar = FALSE;
}
- tracker_add_metadata_to_table (meta_table, g_strdup ("File:Path"), g_strdup (dirname));
- tracker_add_metadata_to_table (meta_table, g_strdup ("File:Name"), g_strdup (filename));
+ tracker_add_metadata_to_table (meta_table,
+ g_strdup ("File:Path"),
+ g_strdup (dirname));
+ tracker_add_metadata_to_table (meta_table,
+ g_strdup ("File:Name"),
+ g_strdup (filename));
if (str_link_uri) {
tracker_add_metadata_to_table (meta_table, g_strdup ("File:Link"), str_link_uri);
}
- tracker_add_metadata_to_table (meta_table, g_strdup ("File:Mime"), g_strdup (info->mime));
- tracker_add_metadata_to_table (meta_table, g_strdup ("File:Size"), tracker_uint_to_string (info->file_size));
- tracker_add_metadata_to_table (meta_table, g_strdup ("File:Modified"), tracker_date_to_string (info->mtime));
- tracker_add_metadata_to_table (meta_table, g_strdup ("File:Accessed"), tracker_date_to_string (info->atime));
+ tracker_add_metadata_to_table (meta_table,
+ g_strdup ("File:Mime"),
+ g_strdup (info->mime));
+ tracker_add_metadata_to_table (meta_table,
+ g_strdup ("File:Size"),
+ tracker_uint_to_string (info->file_size));
+ tracker_add_metadata_to_table (meta_table,
+ g_strdup ("File:Modified"),
+ tracker_date_to_string (info->mtime));
+ tracker_add_metadata_to_table (meta_table,
+ g_strdup ("File:Accessed"),
+ tracker_date_to_string (info->atime));
/* need to add special data for web history */
- if (attachment_service != NULL && strcmp(attachment_service,"WebHistory") == 0) {
-
- gchar* meta_file = g_strconcat(dirname,"/.",filename,NULL);
-
- FILE* fp = g_fopen(meta_file, "r");
+ if (attachment_service != NULL &&
+ strcmp(attachment_service,"WebHistory") == 0) {
+ gchar *meta_file;
+ FILE *fp;
+
+ meta_file = g_strconcat(dirname,"/.",filename,NULL);
+ fp = g_fopen(meta_file, "r");
if (fp != NULL) {
- char buf[512];
+ gchar buf[512];
- fgets(buf,512,fp); //get the first line, it is URL for this web history object
+ fgets (buf,512,fp); /* Get the first
+ * line, it is
+ * URL for this
+ * web history
+ * object
+ */
+
g_debug("URL for this WebHistory is %s\n",buf);
tracker_add_metadata_to_table (meta_table, g_strdup ("Doc:URL"), g_strdup(buf));
- fgets(buf,512,fp);
- fgets(buf,512,fp);
- fgets(buf,512,fp);
- fgets(buf,512,fp); // get the keywords for this file
+ fgets (buf,512,fp);
+ fgets (buf,512,fp);
+ fgets (buf,512,fp);
+ fgets (buf,512,fp); /* Get the
+ * keywords for
+ * this file
+ */
if (buf != NULL) {
-
- /* format like t:dc:keyword=xxx */
- gchar** keys = g_strsplit (buf,"=",0);
-
- if (keys != NULL && strcmp(keys[0],"t:dc:keyword") == 0 && keys[1]) {
+ gchar **keys;
- char *doc_keyword = g_strdup (keys[1]);
+ /* Format like t:dc:keyword=xxx */
+ keys = g_strsplit (buf, "=", 0);
+
+ if (keys != NULL &&
+ strcmp (keys[0], "t:dc:keyword") == 0 &&
+ keys[1]) {
+ gchar *doc_keyword;
+ doc_keyword = g_strdup (keys[1]);
g_debug("found keywords : %s\n",doc_keyword);
-
- tracker_add_metadata_to_table (meta_table, g_strdup ("Doc:Keywords"), doc_keyword);
+ tracker_add_metadata_to_table (meta_table,
+ g_strdup ("Doc:Keywords"),
+ doc_keyword);
}
-
-
- if (keys) g_strfreev(keys);
-
-
+
+ if (keys) {
+ g_strfreev(keys);
+ }
}
fclose (fp);
}
+
g_free (meta_file);
}
-
-
is_external_service = g_str_has_prefix (info->mime, "service/");
is_file_indexable = (!info->is_directory &&
(strcmp (info->mime, "unknown") != 0) &&
@@ -1250,13 +1293,13 @@
(is_external_service ||
(is_file_indexable &&
tracker_ontology_service_type_has_thumbnails (service_name)));
-
- #ifdef HAVE_EXEMPI
+
+#ifdef HAVE_EXEMPI
if (!info->is_directory) {
gchar *basename;
if (ext) {
- basename = g_strndup (filename, (ext - filename -1));
+ basename = g_strndup (filename, (ext - filename - 1));
} else {
basename = g_strdup (filename);
}
@@ -1264,43 +1307,71 @@
if (is_sidecar) {
tracker_db_index_master_files (db_con, dirname, basename, filename);
} else {
- gchar *sidecar_filename = g_strconcat (basename, ".xmp", NULL);
- gchar *sidecar_uri = g_build_filename (dirname, sidecar_filename, NULL);
+ gchar *sidecar_filename;
+ gchar *sidecar_uri;
+ sidecar_filename = g_strconcat (basename, ".xmp", NULL);
+ sidecar_uri = g_build_filename (dirname, sidecar_filename, NULL);
+
+#if 0
if (g_file_test (sidecar_uri, G_FILE_TEST_EXISTS)) {
g_debug ("xmp sidecar found for %s", uri);
+
+ /* FIXME-indexer-split: This has been commented out as a
+ * result of moving tracker-metadata.[ch] to the indexer
+ * directory. This code will be removed when this function is
+ * updated to work correctly in the indexer application.
+ *
+ * -Martyn
+ */
tracker_metadata_get_embedded (sidecar_uri, XMP_MIME_TYPE, meta_table);
}
+#endif
g_free (sidecar_filename);
g_free (sidecar_uri);
}
g_free (basename);
}
- #endif
+#endif /* HAVE_EXEMPI */
- g_debug ("file %s has fulltext %d with service %s", info->uri, service_has_fulltext, service_name);
- tracker_db_index_service (db_con, info, service_name, meta_table, uri, attachment_service, service_has_metadata, service_has_fulltext, service_has_thumbs);
+ g_debug ("file %s has fulltext %d with service %s",
+ info->uri, service_has_fulltext, service_name);
+ tracker_db_index_service (db_con,
+ info,
+ service_name,
+ meta_table,
+ uri,
+ attachment_service,
+ service_has_metadata,
+ service_has_fulltext,
+ service_has_thumbs);
g_hash_table_destroy (meta_table);
g_free (filename);
g_free (dirname);
} else {
- tracker_db_index_service (db_con, info, service_name, NULL, uri, NULL, FALSE, FALSE, FALSE);
-
+ tracker_db_index_service (db_con,
+ info,
+ service_name,
+ NULL,
+ uri,
+ NULL,
+ FALSE,
+ FALSE,
+ FALSE);
}
g_free (service_name);
- if (attachment_uri ) {
+ if (attachment_uri) {
tracker_file_unlink (info->uri);
}
tracker_db_file_info_unref (info);
}
-
void
tracker_db_index_conversation (DBConnection *db_con, TrackerDBFileInfo *info)
{
Modified: branches/indexer-split/src/trackerd/tracker-db.h
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-db.h (original)
+++ branches/indexer-split/src/trackerd/tracker-db.h Wed May 28 10:28:45 2008
@@ -62,8 +62,6 @@
guint32 file_id);
gchar ** tracker_db_get_files_in_folder (DBConnection *db_con,
const gchar *folder_uri);
-gboolean tracker_metadata_is_date (DBConnection *db_con,
- const gchar *meta);
TrackerDBFileInfo *tracker_db_get_pending_file (DBConnection *db_con,
const gchar *uri);
void tracker_db_update_pending_file (DBConnection *db_con,
Modified: branches/indexer-split/src/trackerd/tracker-dbus-files.c
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-dbus-files.c (original)
+++ branches/indexer-split/src/trackerd/tracker-dbus-files.c Wed May 28 10:28:45 2008
@@ -33,7 +33,6 @@
#include "tracker-dbus.h"
#include "tracker-dbus-files.h"
#include "tracker-db.h"
-#include "tracker-metadata.h"
#include "tracker-marshal.h"
#define GET_PRIV(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TRACKER_TYPE_DBUS_FILES, TrackerDBusFilesPriv))
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]