tracker r1978 - in branches/indexer-split: . src/tracker-indexer src/tracker-indexer/modules
- From: carlosg svn gnome org
- To: svn-commits-list gnome org
- Subject: tracker r1978 - in branches/indexer-split: . src/tracker-indexer src/tracker-indexer/modules
- Date: Fri, 1 Aug 2008 12:42:00 +0000 (UTC)
Author: carlosg
Date: Fri Aug 1 12:41:59 2008
New Revision: 1978
URL: http://svn.gnome.org/viewvc/tracker?rev=1978&view=rev
Log:
2008-08-01 Carlos Garnacho <carlos imendio com>
Make tracker-indexer delete items if the module returns NULL metadata,
instead of getting requests from tracker. This is necessary to delete
mails and contents of other container files.
* src/tracker-indexer/tracker-module.h (tracker_module_file_get_uri):
New method for modules to optionally implement. It will return
dirname/basename for the current item.
* src/tracker-indexer/tracker-indexer-module.[ch]
(tracker_indexer_module_file_get_uri): Added wrapping method.
* src/tracker-indexer/tracker-indexer.c: Do not pass the ItemAction
around, instead take the decision based on whether the module returns
metadata or not for the current item. Use new module API to know the
item URI, instead of looking it up in the metadata.
* src/tracker-indexer/tracker-indexer-db.[ch]
(tracker_db_get_service_type) (tracker_db_create_service)
(tracker_db_check_service): Modify API to pass directly the
dirname/basename.
* src/tracker-indexer/modules/dummy.c:
* src/tracker-indexer/modules/files.c:
* src/tracker-indexer/modules/evolution.c: Implement new method where
necessary, also return NULL metadata if the item doesn't exist, was
deleted, etc...
Modified:
branches/indexer-split/ChangeLog
branches/indexer-split/src/tracker-indexer/modules/dummy.c
branches/indexer-split/src/tracker-indexer/modules/evolution.c
branches/indexer-split/src/tracker-indexer/modules/files.c
branches/indexer-split/src/tracker-indexer/tracker-indexer-db.c
branches/indexer-split/src/tracker-indexer/tracker-indexer-db.h
branches/indexer-split/src/tracker-indexer/tracker-indexer-module.c
branches/indexer-split/src/tracker-indexer/tracker-indexer-module.h
branches/indexer-split/src/tracker-indexer/tracker-indexer.c
branches/indexer-split/src/tracker-indexer/tracker-module.h
Modified: branches/indexer-split/src/tracker-indexer/modules/dummy.c
==============================================================================
--- branches/indexer-split/src/tracker-indexer/modules/dummy.c (original)
+++ branches/indexer-split/src/tracker-indexer/modules/dummy.c Fri Aug 1 12:41:59 2008
@@ -70,6 +70,22 @@
*/
}
+void
+tracker_module_file_get_uri (TrackerFile *file,
+ gchar **dirname,
+ gchar **basename)
+{
+ /* Implementing this function is optional
+ *
+ * Return dirname/basename for the current item, with this
+ * method modules can specify different URIs for different
+ * elements contained in the file. Also see
+ * tracker_module_file_iter_contents()
+ */
+ *dirname = g_path_get_dirname (file->path);
+ *basename = g_path_get_basename (file->path);
+}
+
TrackerMetadata *
tracker_module_file_get_metadata (TrackerFile *file)
{
Modified: branches/indexer-split/src/tracker-indexer/modules/evolution.c
==============================================================================
--- branches/indexer-split/src/tracker-indexer/modules/evolution.c (original)
+++ branches/indexer-split/src/tracker-indexer/modules/evolution.c Fri Aug 1 12:41:59 2008
@@ -88,6 +88,19 @@
gchar *uid;
};
+enum EvolutionFlags {
+ EVOLUTION_MESSAGE_ANSWERED = 1 << 0,
+ EVOLUTION_MESSAGE_DELETED = 1 << 1,
+ EVOLUTION_MESSAGE_DRAFT = 1 << 2,
+ EVOLUTION_MESSAGE_FLAGGED = 1 << 3,
+ EVOLUTION_MESSAGE_SEEN = 1 << 4,
+ EVOLUTION_MESSAGE_ATTACHMENTS = 1 << 5,
+ EVOLUTION_MESSAGE_ANSWERED_ALL = 1 << 6,
+ EVOLUTION_MESSAGE_JUNK = 1 << 7,
+ EVOLUTION_MESSAGE_SECURE = 1 << 8
+};
+
+
static gchar *local_dir = NULL;
static gchar *imap_dir = NULL;
static GHashTable *accounts = NULL;
@@ -548,7 +561,7 @@
g_slice_free (EvolutionFileData, data);
}
-gint
+static gint
get_mbox_message_id (GMimeMessage *message)
{
const gchar *header, *pos;
@@ -566,6 +579,34 @@
return id;
}
+static guint
+get_mbox_message_flags (GMimeMessage *message)
+{
+ const gchar *header, *pos;
+
+ header = g_mime_message_get_header (message, "X-Evolution");
+ pos = strchr (header, '-');
+
+ return (guint) strtoul (pos + 1, NULL, 16);
+}
+
+static void
+get_mbox_uri (TrackerFile *file,
+ GMimeMessage *message,
+ gchar **dirname,
+ gchar **basename)
+{
+ gchar *dir, *name;
+
+ dir = tracker_string_replace (file->path, local_dir, NULL);
+ name = g_strdup_printf ("%s;uid=%d", dir, get_mbox_message_id (message));
+
+ *dirname = g_strdup ("email://local local");
+ *basename = name;
+
+ g_free (dir);
+}
+
static GList *
get_mbox_recipient_list (GMimeMessage *message,
const gchar *type)
@@ -602,10 +643,11 @@
EvolutionLocalData *data;
GMimeMessage *message;
TrackerMetadata *metadata;
- gchar *dir, *name, *body;
+ gchar *dirname, *basename, *body;
gboolean is_html;
time_t date;
GList *list;
+ guint flags;
data = file->data;
message = data->message;
@@ -614,12 +656,18 @@
return NULL;
}
+ flags = get_mbox_message_flags (message);
+
+ if (flags & EVOLUTION_MESSAGE_JUNK ||
+ flags & EVOLUTION_MESSAGE_DELETED) {
+ return NULL;
+ }
+
metadata = tracker_metadata_new ();
- dir = tracker_string_replace (file->path, local_dir, NULL);
- name = g_strdup_printf ("%s;uid=%d", dir, get_mbox_message_id (message));
- tracker_metadata_insert (metadata, METADATA_FILE_PATH, g_strdup ("email://local local"));
- tracker_metadata_insert (metadata, METADATA_FILE_NAME, name);
+ get_mbox_uri (file, message, &dirname, &basename);
+ tracker_metadata_insert (metadata, METADATA_FILE_PATH, dirname);
+ tracker_metadata_insert (metadata, METADATA_FILE_NAME, basename);
g_mime_message_get_date (message, &date, NULL);
tracker_metadata_insert (metadata, METADATA_EMAIL_DATE,
@@ -641,8 +689,6 @@
/* FIXME: Missing attachments handling */
- g_free (dir);
-
return metadata;
}
@@ -685,13 +731,14 @@
}
void
-get_imap_uri (const gchar *path,
+get_imap_uri (TrackerFile *file,
gchar **uri_base,
gchar **basename)
{
GList *keys, *k;
- gchar *dir, *subdirs;
+ gchar *path, *dir, *subdirs;
+ path = file->path;
keys = g_hash_table_get_keys (accounts);
*uri_base = *basename = NULL;
@@ -769,7 +816,7 @@
TrackerMetadata *metadata;
gchar *dirname, *basename;
gchar *uid, *subject, *from, *to, *cc, *body;
- gint32 i, count;
+ gint32 i, count, flags;
time_t date;
GList *list;
@@ -781,7 +828,16 @@
read_summary (data->summary,
SUMMARY_TYPE_STRING, &uid, /* message uid */
- SUMMARY_TYPE_UINT32, NULL, /* flags */
+ SUMMARY_TYPE_UINT32, &flags, /* flags */
+ -1);
+
+ if (flags & EVOLUTION_MESSAGE_JUNK ||
+ flags & EVOLUTION_MESSAGE_DELETED) {
+ g_free (uid);
+ return NULL;
+ }
+
+ read_summary (data->summary,
SUMMARY_TYPE_UINT32, NULL, /* size */
SUMMARY_TYPE_TIME_T, NULL, /* date sent */
SUMMARY_TYPE_TIME_T, &date, /* date received */
@@ -793,7 +849,7 @@
-1);
metadata = tracker_metadata_new ();
- get_imap_uri (file->path, &dirname, &basename);
+ get_imap_uri (file, &dirname, &basename);
tracker_metadata_insert (metadata, METADATA_FILE_PATH, dirname);
tracker_metadata_insert (metadata, METADATA_FILE_NAME, g_strdup_printf ("%s;uid=%s", basename, uid));
@@ -859,6 +915,41 @@
return metadata;
}
+void
+tracker_module_file_get_uri (TrackerFile *file,
+ gchar **dirname,
+ gchar **basename)
+{
+ EvolutionFileData *file_data;
+
+ file_data = file->data;
+
+ if (!file_data) {
+ /* It isn't any of the files the
+ * module is interested for */
+ return;
+ }
+
+ switch (file_data->type) {
+ case MAIL_STORAGE_LOCAL: {
+ EvolutionLocalData *data = file->data;
+
+ if (!data->message) {
+ return;
+ }
+
+ get_mbox_uri (file, data->message, dirname, basename);
+ break;
+ }
+ case MAIL_STORAGE_IMAP: {
+ get_imap_uri (file, dirname, basename);
+ break;
+ }
+ default:
+ break;
+ }
+}
+
TrackerMetadata *
tracker_module_file_get_metadata (TrackerFile *file)
{
Modified: branches/indexer-split/src/tracker-indexer/modules/files.c
==============================================================================
--- branches/indexer-split/src/tracker-indexer/modules/files.c (original)
+++ branches/indexer-split/src/tracker-indexer/modules/files.c Fri Aug 1 12:41:59 2008
@@ -206,11 +206,14 @@
path = file->path;
- if (check_exclude_file (path)) {
- return NULL;
- }
+ if (check_exclude_file (path)) {
+ return NULL;
+ }
+
+ if (g_lstat (path, &st) < 0) {
+ return NULL;
+ }
- g_lstat (path, &st);
metadata = tracker_metadata_new ();
ext = strrchr (path, '.');
Modified: branches/indexer-split/src/tracker-indexer/tracker-indexer-db.c
==============================================================================
--- branches/indexer-split/src/tracker-indexer/tracker-indexer-db.c (original)
+++ branches/indexer-split/src/tracker-indexer/tracker-indexer-db.c Fri Aug 1 12:41:59 2008
@@ -125,39 +125,15 @@
g_free (service_id_str);
}
-static void
-get_dirname_and_basename (const gchar *path,
- TrackerMetadata *metadata,
- gchar **out_dirname,
- gchar **out_basename)
-{
- const gchar *dirname = NULL, *basename = NULL;
-
- if (metadata) {
- dirname = tracker_metadata_lookup (metadata, "File:Path");
- basename = tracker_metadata_lookup (metadata, "File:Name");
- }
-
- if (dirname && basename) {
- *out_dirname = g_strdup (dirname);
- *out_basename = g_strdup (basename);
- } else {
- *out_dirname = g_path_get_dirname (path);
- *out_basename = g_path_get_basename (path);
- }
-}
-
guint
tracker_db_check_service (TrackerService *service,
- const gchar *path,
- TrackerMetadata *metadata)
+ const gchar *dirname,
+ const gchar *basename)
{
TrackerDBInterface *iface;
TrackerDBResultSet *result_set;
- gchar *dirname, *basename;
guint id;
- get_dirname_and_basename (path, metadata, &dirname, &basename);
iface = tracker_db_manager_get_db_interface_by_type (tracker_service_get_name (service),
TRACKER_DB_CONTENT_TYPE_METADATA);
@@ -166,9 +142,6 @@
dirname,
basename,
NULL);
- g_free (dirname);
- g_free (basename);
-
if (!result_set) {
return 0;
}
@@ -180,15 +153,13 @@
}
guint
-tracker_db_get_service_type (const gchar *path)
+tracker_db_get_service_type (const gchar *dirname,
+ const gchar *basename)
{
TrackerDBInterface *iface;
TrackerDBResultSet *result_set;
- gchar *dirname, *basename;
guint service_type_id;
- get_dirname_and_basename (path, NULL, &dirname, &basename);
-
/* We are asking this because the module cannot assign service_type -> probably it is files */
iface = tracker_db_manager_get_db_interface_by_type ("Files",
TRACKER_DB_CONTENT_TYPE_METADATA);
@@ -198,9 +169,6 @@
dirname,
basename,
NULL);
- g_free (dirname);
- g_free (basename);
-
if (!result_set) {
return 0;
}
@@ -214,25 +182,26 @@
gboolean
tracker_db_create_service (TrackerService *service,
guint32 id,
- const gchar *path,
+ const gchar *dirname,
+ const gchar *basename,
TrackerMetadata *metadata)
{
TrackerDBInterface *iface;
- gchar *id_str, *service_type_id_str;
- gchar *dirname, *basename;
+ gchar *id_str, *service_type_id_str, *path;
gboolean is_dir, is_symlink, enabled;
if (!service) {
return FALSE;
}
- get_dirname_and_basename (path, metadata, &dirname, &basename);
iface = tracker_db_manager_get_db_interface_by_type (tracker_service_get_name (service),
TRACKER_DB_CONTENT_TYPE_METADATA);
id_str = tracker_guint32_to_string (id);
service_type_id_str = tracker_int_to_string (tracker_service_get_id (service));
+ path = g_build_filename (dirname, basename, NULL);
+
is_dir = g_file_test (path, G_FILE_TEST_IS_DIR);
is_symlink = g_file_test (path, G_FILE_TEST_IS_SYMLINK);
@@ -263,8 +232,7 @@
g_free (id_str);
g_free (service_type_id_str);
- g_free (dirname);
- g_free (basename);
+ g_free (path);
return TRUE;
}
Modified: branches/indexer-split/src/tracker-indexer/tracker-indexer-db.h
==============================================================================
--- branches/indexer-split/src/tracker-indexer/tracker-indexer-db.h (original)
+++ branches/indexer-split/src/tracker-indexer/tracker-indexer-db.h Fri Aug 1 12:41:59 2008
@@ -34,15 +34,16 @@
TrackerService *service);
/* Using path */
guint tracker_db_check_service (TrackerService *service,
- const gchar *path,
- TrackerMetadata *metadata);
-guint tracker_db_get_service_type (const gchar *path);
-
+ const gchar *dirname,
+ const gchar *basename);
+guint tracker_db_get_service_type (const gchar *dirname,
+ const gchar *basename);
/* Services */
gboolean tracker_db_create_service (TrackerService *service,
guint32 id,
- const gchar *path,
+ const gchar *dirname,
+ const gchar *basename,
TrackerMetadata *metadata);
void tracker_db_delete_service (TrackerService *service,
guint32 id);
Modified: branches/indexer-split/src/tracker-indexer/tracker-indexer-module.c
==============================================================================
--- branches/indexer-split/src/tracker-indexer/tracker-indexer-module.c (original)
+++ branches/indexer-split/src/tracker-indexer/tracker-indexer-module.c Fri Aug 1 12:41:59 2008
@@ -115,6 +115,42 @@
g_slice_free (TrackerFile, file);
}
+gboolean
+tracker_indexer_module_file_get_uri (GModule *module,
+ TrackerFile *file,
+ gchar **dirname,
+ gchar **basename)
+{
+ TrackerModuleFileGetUriFunc func;
+ gchar *tmp_dirname, *tmp_basename;
+
+ tmp_dirname = tmp_basename = NULL;
+
+ if (g_module_symbol (module, "tracker_module_file_get_uri", (gpointer *) &func)) {
+ (func) (file, &tmp_dirname, &tmp_basename);
+ } else {
+ tmp_dirname = g_path_get_dirname (file->path);
+ tmp_basename = g_path_get_basename (file->path);
+ }
+
+ if (tmp_dirname && tmp_basename) {
+ if (dirname) {
+ *dirname = tmp_dirname;
+ }
+
+ if (basename) {
+ *basename = tmp_basename;
+ }
+
+ return TRUE;
+ } else {
+ g_free (tmp_dirname);
+ g_free (tmp_basename);
+
+ return FALSE;
+ }
+}
+
TrackerMetadata *
tracker_indexer_module_file_get_metadata (GModule *module,
TrackerFile *file)
Modified: branches/indexer-split/src/tracker-indexer/tracker-indexer-module.h
==============================================================================
--- branches/indexer-split/src/tracker-indexer/tracker-indexer-module.h (original)
+++ branches/indexer-split/src/tracker-indexer/tracker-indexer-module.h Fri Aug 1 12:41:59 2008
@@ -28,26 +28,30 @@
G_BEGIN_DECLS
-GModule * tracker_indexer_module_load (const gchar *module_name);
+GModule * tracker_indexer_module_load (const gchar *module_name);
-void tracker_indexer_module_init (GModule *module);
-void tracker_indexer_module_shutdown (GModule *module);
+void tracker_indexer_module_init (GModule *module);
+void tracker_indexer_module_shutdown (GModule *module);
-G_CONST_RETURN gchar * tracker_indexer_module_get_name (GModule *module);
+G_CONST_RETURN gchar * tracker_indexer_module_get_name (GModule *module);
-TrackerFile * tracker_indexer_module_file_new (GModule *module,
- const gchar *module_name,
- const gchar *path);
-void tracker_indexer_module_file_free (GModule *module,
- TrackerFile *file);
-
-TrackerMetadata * tracker_indexer_module_file_get_metadata (GModule *module,
- TrackerFile *file);
-gchar * tracker_indexer_module_file_get_text (GModule *module,
- TrackerFile *file);
+TrackerFile * tracker_indexer_module_file_new (GModule *module,
+ const gchar *module_name,
+ const gchar *path);
+void tracker_indexer_module_file_free (GModule *module,
+ TrackerFile *file);
+
+gboolean tracker_indexer_module_file_get_uri (GModule *module,
+ TrackerFile *file,
+ gchar **dirname,
+ gchar **basename);
+TrackerMetadata * tracker_indexer_module_file_get_metadata (GModule *module,
+ TrackerFile *file);
+gchar * tracker_indexer_module_file_get_text (GModule *module,
+ TrackerFile *file);
-gboolean tracker_indexer_module_file_iter_contents (GModule *module,
- TrackerFile *file);
+gboolean tracker_indexer_module_file_iter_contents (GModule *module,
+ TrackerFile *file);
G_END_DECLS
Modified: branches/indexer-split/src/tracker-indexer/tracker-indexer.c
==============================================================================
--- branches/indexer-split/src/tracker-indexer/tracker-indexer.c (original)
+++ branches/indexer-split/src/tracker-indexer/tracker-indexer.c Fri Aug 1 12:41:59 2008
@@ -129,16 +129,9 @@
gboolean is_paused;
};
-typedef enum {
- TRACKER_ITEM_ACTION_CREATE,
- TRACKER_ITEM_ACTION_DELETE,
- TRACKER_ITEM_ACTION_UPDATE
-} ItemAction;
-
struct PathInfo {
GModule *module;
TrackerFile *file;
- ItemAction action;
};
struct MetadataForeachData {
@@ -175,15 +168,13 @@
static PathInfo *
path_info_new (GModule *module,
const gchar *module_name,
- const gchar *path,
- ItemAction action)
+ const gchar *path)
{
PathInfo *info;
info = g_slice_new (PathInfo);
info->module = module;
info->file = tracker_indexer_module_file_new (module, module_name, path);
- info->action = action;
return info;
}
@@ -859,99 +850,94 @@
send_text_to_index (indexer, service_id, service_type_id, content, FALSE, -1 * weight_factor);
}
-static gboolean
-handle_file_create (TrackerIndexer *indexer,
- PathInfo *info)
+static void
+create_update_item (TrackerIndexer *indexer,
+ PathInfo *info,
+ TrackerMetadata *metadata)
{
- TrackerMetadata *metadata;
+ TrackerService *service_def;
+ gchar *dirname, *basename;
+ gchar *service_type;
+ gchar *text;
+ guint32 id;
- /* Process file */
- metadata = tracker_indexer_module_file_get_metadata (info->module, info->file);
+ service_type = g_strdup (tracker_module_config_get_index_service (info->file->module_name));
- if (metadata) {
- TrackerService *service_def;
- gchar *service_type;
- gchar *text;
- guint32 id;
-
- service_type = g_strdup (tracker_module_config_get_index_service (info->file->module_name));
-
- if (!service_type || !service_type[0]) {
- gchar *mimetype;
-
- g_free (service_type);
- mimetype = tracker_file_get_mime_type (info->file->path);
- service_type = tracker_ontology_get_service_type_for_mime (mimetype);
- g_free (mimetype);
- }
+ if (!service_type || !service_type[0]) {
+ gchar *mimetype;
- service_def = tracker_ontology_get_service_type_by_name (service_type);
g_free (service_type);
+ mimetype = tracker_file_get_mime_type (info->file->path);
+ service_type = tracker_ontology_get_service_type_for_mime (mimetype);
+ g_free (mimetype);
+ }
- if (service_def) {
- id = tracker_db_check_service (service_def, info->file->path, metadata);
+ service_def = tracker_ontology_get_service_type_by_name (service_type);
+ g_free (service_type);
- /* FIXME: should check mtime and reindex if necessary */
+ if (!service_def) {
+ return;
+ }
- if (id == 0) {
- /* Service wasn't previously indexed */
- id = tracker_db_get_new_service_id (indexer->private->common);
-
- tracker_db_create_service (service_def,
- id,
- info->file->path,
- metadata);
-
- tracker_db_create_event (indexer->private->cache, id, "Create");
- tracker_db_increment_stats (indexer->private->common, service_def);
-
- index_metadata (indexer, id, service_def, metadata);
-
- text = tracker_indexer_module_file_get_text (info->module, info->file);
-
- if (text) {
- /* Save in the index */
- index_text_with_parsing (indexer,
- id,
- tracker_service_get_id (service_def),
- text,
- 1);
- /* Save in the DB */
- tracker_db_set_text (service_def, id, text);
- g_free (text);
- }
- }
+ tracker_indexer_module_file_get_uri (info->module, info->file, &dirname, &basename);
+ id = tracker_db_check_service (service_def, dirname, basename);
- }
+ /* FIXME: should check mtime and reindex if necessary */
- tracker_metadata_free (metadata);
+ if (id == 0) {
+ /* Service wasn't previously indexed */
+ id = tracker_db_get_new_service_id (indexer->private->common);
+
+ tracker_db_create_service (service_def,
+ id,
+ dirname,
+ basename,
+ metadata);
+
+ tracker_db_create_event (indexer->private->cache, id, "Create");
+ tracker_db_increment_stats (indexer->private->common, service_def);
+
+ index_metadata (indexer, id, service_def, metadata);
+
+ text = tracker_indexer_module_file_get_text (info->module, info->file);
+
+ if (text) {
+ /* Save in the index */
+ index_text_with_parsing (indexer,
+ id,
+ tracker_service_get_id (service_def),
+ text,
+ 1);
+ /* Save in the DB */
+ tracker_db_set_text (service_def, id, text);
+ g_free (text);
+ }
}
- indexer->private->items_processed++;
-
- return !tracker_indexer_module_file_iter_contents (info->module, info->file);
+ g_free (dirname);
+ g_free (basename);
}
-static gboolean
-handle_file_delete (TrackerIndexer *indexer,
- PathInfo *info)
+static void
+delete_item (TrackerIndexer *indexer,
+ PathInfo *info)
{
-
TrackerService *service_def;
- gchar *content;
- const gchar *service_type = NULL;
- guint service_id;
- guint service_type_id;
- gchar *metadata;
-
+ gchar *dirname, *basename, *content, *metadata;
+ const gchar *service_type = NULL;
+ guint service_id, service_type_id;
service_type = tracker_module_config_get_index_service (info->file->module_name);
+ if (!tracker_indexer_module_file_get_uri (info->module, info->file, &dirname, &basename)) {
+ return;
+ }
+
if (!service_type || !service_type[0]) {
gchar *name;
/* The file is not anymore in the filesystem. Obtain the service type from the DB */
- service_type_id = tracker_db_get_service_type (info->file->path);
+ service_type_id = tracker_db_get_service_type (dirname, basename);
name = tracker_ontology_get_service_type_by_id (service_type_id);
service_def = tracker_ontology_get_service_type_by_name (name);
@@ -961,14 +947,16 @@
service_type_id = tracker_service_get_id (service_def);
}
- service_id = tracker_db_check_service (service_def, info->file->path, NULL);
+ service_id = tracker_db_check_service (service_def, dirname, basename);
+
+ g_free (dirname);
+ g_free (basename);
if (service_id < 1) {
g_message ("Cannot delete file: it doesnt exist in DB");
- return TRUE;
+ return;
}
-
/* Get content, unindex the words and delete the contents */
content = tracker_db_get_text (service_def, service_id);
if (content) {
@@ -977,13 +965,11 @@
tracker_db_delete_text (service_def, service_id);
}
-
/* Get metadata from DB to remove it from the index */
metadata = tracker_db_get_parsed_metadata (service_def, service_id);
unindex_text_no_parsing (indexer, service_id, service_type_id, metadata, 1000);
g_free (metadata);
-
/* the weight depends on metadata, but a number high enough force deletion */
metadata = tracker_db_get_unparsed_metadata (service_def, service_id);
unindex_text_with_parsing (indexer, service_id, service_type_id, metadata, 1000);
@@ -994,10 +980,6 @@
tracker_db_delete_all_metadata (service_def, service_id);
tracker_db_decrement_stats (indexer->private->common, service_def);
-
- indexer->private->items_processed++;
-
- return !tracker_indexer_module_file_iter_contents (info->module, info->file);
}
static gboolean
@@ -1008,9 +990,9 @@
GStrv values)
{
TrackerService *service_def;
- TrackerField *field_def;
- guint service_id, i;
- gchar *joined;
+ TrackerField *field_def;
+ guint service_id, i;
+ gchar *joined, *dirname, *basename;
service_def = tracker_ontology_get_service_type_by_name (service_type);
if (!service_def) {
@@ -1022,7 +1004,14 @@
return FALSE;
}
- service_id = tracker_db_check_service (service_def, uri, NULL);
+ dirname = tracker_file_get_vfs_path (uri);
+ basename = tracker_file_get_vfs_name (uri);
+
+ service_id = tracker_db_check_service (service_def, dirname, basename);
+
+ g_free (dirname);
+ g_free (basename);
+
if (service_id < 1) {
g_message ("Cannot delete file: it doesnt exist in DB");
return FALSE;
@@ -1056,9 +1045,9 @@
GStrv values)
{
TrackerService *service_def;
- TrackerField *field_def;
- guint service_id, i;
- gchar *joined;
+ TrackerField *field_def;
+ guint service_id, i;
+ gchar *joined, *dirname, *basename;
service_def = tracker_ontology_get_service_type_by_name (service_type);
if (!service_def) {
@@ -1070,7 +1059,14 @@
return FALSE;
}
- service_id = tracker_db_check_service (service_def, uri, NULL);
+ dirname = tracker_file_get_vfs_path (uri);
+ basename = tracker_file_get_vfs_name (uri);
+
+ service_id = tracker_db_check_service (service_def, dirname, basename);
+
+ g_free (dirname);
+ g_free (basename);
+
if (service_id < 1) {
g_message ("Cannot delete file: it doesnt exist in DB");
return FALSE;
@@ -1098,6 +1094,8 @@
process_file (TrackerIndexer *indexer,
PathInfo *info)
{
+ TrackerMetadata *metadata;
+
g_debug ("Processing file:'%s'", info->file->path);
/* Set the current module */
@@ -1107,20 +1105,19 @@
/* Sleep to throttle back indexing */
indexer_throttle (indexer->private->config, 100);
- switch (info->action) {
- case TRACKER_ITEM_ACTION_CREATE:
- case TRACKER_ITEM_ACTION_UPDATE:
- return handle_file_create (indexer, info);
-
- case TRACKER_ITEM_ACTION_DELETE:
- return handle_file_delete (indexer, info);
+ metadata = tracker_indexer_module_file_get_metadata (info->module, info->file);
- default:
- g_critical ("Action not support in indexer");
- return FALSE;
+ if (metadata) {
+ /* Create/Update item */
+ create_update_item (indexer, info, metadata);
+ tracker_metadata_free (metadata);
+ } else {
+ delete_item (indexer, info);
}
+ indexer->private->items_processed++;
+ return !tracker_indexer_module_file_iter_contents (info->module, info->file);
}
static void
@@ -1145,11 +1142,11 @@
path = g_build_filename (info->file->path, name, NULL);
- new_info = path_info_new (info->module, info->file->module_name, path, TRACKER_ITEM_ACTION_CREATE);
+ new_info = path_info_new (info->module, info->file->module_name, path);
add_file (indexer, new_info);
if (recurse && g_file_test (path, G_FILE_TEST_IS_DIR)) {
- new_info = path_info_new (info->module, info->file->module_name, path, TRACKER_ITEM_ACTION_CREATE);
+ new_info = path_info_new (info->module, info->file->module_name, path);
add_directory (indexer, new_info);
}
@@ -1206,7 +1203,7 @@
for (d = dirs; d; d = d->next) {
PathInfo *info;
- info = path_info_new (module, module_name, d->data, TRACKER_ITEM_ACTION_CREATE);
+ info = path_info_new (module, module_name, d->data);
add_directory (indexer, info);
}
@@ -1411,7 +1408,6 @@
tracker_dbus_request_success (request_id);
}
-
void
tracker_indexer_process_all (TrackerIndexer *indexer)
{
@@ -1450,7 +1446,7 @@
for (i = 0; files[i]; i++) {
PathInfo *info;
- info = path_info_new (module, module_name, files[i], TRACKER_ITEM_ACTION_CREATE);
+ info = path_info_new (module, module_name, files[i]);
add_file (indexer, info);
}
} else {
@@ -1469,6 +1465,7 @@
}
}
+/* FIXME: Should get rid of this DBus method */
void
tracker_indexer_files_update (TrackerIndexer *indexer,
const gchar *module_name,
@@ -1476,46 +1473,11 @@
DBusGMethodInvocation *context,
GError **error)
{
- GModule *module;
- guint request_id;
- gint i;
- GError *actual_error = NULL;
-
- request_id = tracker_dbus_get_next_request_id ();
-
- tracker_dbus_async_return_if_fail (TRACKER_IS_INDEXER (indexer), FALSE);
- tracker_dbus_async_return_if_fail (files != NULL, FALSE);
-
- tracker_dbus_request_new (request_id,
- "DBus request to update %d files",
- g_strv_length (files));
-
- module = g_hash_table_lookup (indexer->private->indexer_modules, module_name);
-
- if (module) {
- /* Add files to the queue */
- for (i = 0; files[i]; i++) {
- PathInfo *info;
-
- info = path_info_new (module, module_name, files[i], TRACKER_ITEM_ACTION_UPDATE);
- add_file (indexer, info);
- }
- } else {
- tracker_dbus_request_failed (request_id,
- &actual_error,
- "The module '%s' is not loaded",
- module_name);
- }
-
- if (!actual_error) {
- dbus_g_method_return (context);
- tracker_dbus_request_success (request_id);
- } else {
- dbus_g_method_return_error (context, actual_error);
- g_error_free (actual_error);
- }
+ tracker_indexer_files_check (indexer, module_name,
+ files, context, error);
}
+/* FIXME: Should get rid of this DBus method */
void
tracker_indexer_files_delete (TrackerIndexer *indexer,
const gchar *module_name,
@@ -1523,45 +1485,8 @@
DBusGMethodInvocation *context,
GError **error)
{
- GModule *module;
- guint request_id;
- gint i;
- GError *actual_error = NULL;
-
- request_id = tracker_dbus_get_next_request_id ();
-
- tracker_dbus_async_return_if_fail (TRACKER_IS_INDEXER (indexer), FALSE);
- tracker_dbus_async_return_if_fail (files != NULL, FALSE);
-
- tracker_dbus_request_new (request_id,
- "DBus request to delete %d files",
- g_strv_length (files));
-
- module = g_hash_table_lookup (indexer->private->indexer_modules, module_name);
-
- if (module) {
- /* Add files to the queue */
- for (i = 0; files[i]; i++) {
- PathInfo *info;
-
- info = path_info_new (module, module_name, files[i], TRACKER_ITEM_ACTION_DELETE);
- add_file (indexer, info);
- }
-
- } else {
- tracker_dbus_request_failed (request_id,
- &actual_error,
- "The module '%s' is not loaded",
- module_name);
- }
-
- if (!actual_error) {
- dbus_g_method_return (context);
- tracker_dbus_request_success (request_id);
- } else {
- dbus_g_method_return_error (context, actual_error);
- g_error_free (actual_error);
- }
+ tracker_indexer_files_check (indexer, module_name,
+ files, context, error);
}
void
Modified: branches/indexer-split/src/tracker-indexer/tracker-module.h
==============================================================================
--- branches/indexer-split/src/tracker-indexer/tracker-module.h (original)
+++ branches/indexer-split/src/tracker-indexer/tracker-module.h Fri Aug 1 12:41:59 2008
@@ -42,6 +42,10 @@
typedef gpointer (* TrackerModuleFileGetDataFunc) (const gchar *path);
typedef void (* TrackerModuleFileFreeDataFunc) (gpointer data);
+typedef void (* TrackerModuleFileGetUriFunc) (TrackerFile *file,
+ gchar **dirname,
+ gchar **basename);
+
typedef TrackerMetadata * (* TrackerModuleFileGetMetadataFunc) (TrackerFile *file);
typedef gchar * (* TrackerModuleFileGetText) (TrackerFile *path);
typedef gboolean (* TrackerModuleFileIterContents) (TrackerFile *path);
@@ -55,6 +59,10 @@
gpointer tracker_module_file_get_data (const gchar *path);
void tracker_module_file_free_data (gpointer file_data);
+void tracker_module_file_get_uri (TrackerFile *file,
+ gchar **dirname,
+ gchar **basename);
+
TrackerMetadata * tracker_module_file_get_metadata (TrackerFile *file);
gchar * tracker_module_file_get_text (TrackerFile *file);
gboolean tracker_module_file_iter_contents (TrackerFile *file);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]