tracker r1565 - in branches/xesam-support: . src/libtracker-common src/tracker-indexer src/trackerd
- From: pvanhoof svn gnome org
- To: svn-commits-list gnome org
- Subject: tracker r1565 - in branches/xesam-support: . src/libtracker-common src/tracker-indexer src/trackerd
- Date: Mon, 2 Jun 2008 18:57:27 +0000 (UTC)
Author: pvanhoof
Date: Mon Jun 2 18:57:26 2008
New Revision: 1565
URL: http://svn.gnome.org/viewvc/tracker?rev=1565&view=rev
Log:
* svn merge -r 1559:1564 ../indexer-split
Added:
branches/xesam-support/src/trackerd/tracker-watcher-fam.c
- copied unchanged from r1564, /branches/indexer-split/src/trackerd/tracker-watcher-fam.c
branches/xesam-support/src/trackerd/tracker-watcher-inotify.c
- copied unchanged from r1564, /branches/indexer-split/src/trackerd/tracker-watcher-inotify.c
branches/xesam-support/src/trackerd/tracker-watcher-poll.c
- copied unchanged from r1564, /branches/indexer-split/src/trackerd/tracker-watcher-poll.c
branches/xesam-support/src/trackerd/tracker-watcher-win.c
- copied unchanged from r1564, /branches/indexer-split/src/trackerd/tracker-watcher-win.c
branches/xesam-support/src/trackerd/tracker-watcher.h
- copied unchanged from r1564, /branches/indexer-split/src/trackerd/tracker-watcher.h
Removed:
branches/xesam-support/src/trackerd/tracker-cache.c
branches/xesam-support/src/trackerd/tracker-cache.h
branches/xesam-support/src/trackerd/tracker-fam.c
branches/xesam-support/src/trackerd/tracker-inotify.c
branches/xesam-support/src/trackerd/tracker-poll.c
branches/xesam-support/src/trackerd/tracker-watch.h
branches/xesam-support/src/trackerd/tracker-win-fs-changes.c
Modified:
branches/xesam-support/ChangeLog
branches/xesam-support/src/libtracker-common/tracker-field.h
branches/xesam-support/src/libtracker-common/tracker-ontology.c
branches/xesam-support/src/tracker-indexer/tracker-indexer-db.c
branches/xesam-support/src/trackerd/Makefile.am
branches/xesam-support/src/trackerd/tracker-db-email.c
branches/xesam-support/src/trackerd/tracker-db-sqlite.c
branches/xesam-support/src/trackerd/tracker-db.c
branches/xesam-support/src/trackerd/tracker-dbus.c
branches/xesam-support/src/trackerd/tracker-email-evolution.c
branches/xesam-support/src/trackerd/tracker-email-kmail.c
branches/xesam-support/src/trackerd/tracker-email-modest.c
branches/xesam-support/src/trackerd/tracker-email-thunderbird.c
branches/xesam-support/src/trackerd/tracker-email-utils.c
branches/xesam-support/src/trackerd/tracker-indexer.c
branches/xesam-support/src/trackerd/tracker-main.c
branches/xesam-support/src/trackerd/tracker-main.h
branches/xesam-support/src/trackerd/tracker-process-files.c
branches/xesam-support/src/trackerd/tracker-process-files.h
branches/xesam-support/src/trackerd/tracker-utils.c
branches/xesam-support/src/trackerd/tracker-xesam-manager.c
branches/xesam-support/src/trackerd/tracker-xesam-manager.h
Modified: branches/xesam-support/src/libtracker-common/tracker-field.h
==============================================================================
--- branches/xesam-support/src/libtracker-common/tracker-field.h (original)
+++ branches/xesam-support/src/libtracker-common/tracker-field.h Mon Jun 2 18:57:26 2008
@@ -44,6 +44,7 @@
GType tracker_field_type_get_type (void) G_GNUC_CONST;
#define TRACKER_TYPE_FIELD (tracker_field_get_type ())
+#define TRACKER_TYPE_FIELD_TYPE (tracker_field_type_get_type ())
#define TRACKER_FIELD(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), TRACKER_TYPE_FIELD, TrackerField))
#define TRACKER_FIELD_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), TRACKER_TYPE_FIELD, TrackerFieldClass))
#define TRACKER_IS_FIELD(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), TRACKER_TYPE_FIELD))
Modified: branches/xesam-support/src/libtracker-common/tracker-ontology.c
==============================================================================
--- branches/xesam-support/src/libtracker-common/tracker-ontology.c (original)
+++ branches/xesam-support/src/libtracker-common/tracker-ontology.c Mon Jun 2 18:57:26 2008
@@ -53,6 +53,9 @@
/* Field descriptions */
static GHashTable *metadata_table;
+/* FieldType enum class */
+static gpointer field_type_enum_class;
+
static void
@@ -127,6 +130,12 @@
g_str_equal,
NULL, //Pointer to the object name
g_object_unref);
+
+ /* We will need the class later in order to match strings to enum values
+ * when inserting metadata types in the DB, so the enum class needs to be
+ * created beforehand.
+ */
+ field_type_enum_class = g_type_class_ref (TRACKER_TYPE_FIELD_TYPE);
}
void
@@ -144,6 +153,9 @@
NULL);
g_slist_free (mime_prefix_service);
}
+
+ g_type_class_unref (field_type_enum_class);
+ field_type_enum_class = NULL;
}
void
Modified: branches/xesam-support/src/tracker-indexer/tracker-indexer-db.c
==============================================================================
--- branches/xesam-support/src/tracker-indexer/tracker-indexer-db.c (original)
+++ branches/xesam-support/src/tracker-indexer/tracker-indexer-db.c Mon Jun 2 18:57:26 2008
@@ -43,9 +43,9 @@
g_message ("Loading prepared queries...");
- prepared_queries = g_hash_table_new_full (g_str_hash,
- g_str_equal,
- g_free,
+ prepared_queries = g_hash_table_new_full (g_str_hash,
+ g_str_equal,
+ g_free,
g_free);
sql_filename = tracker_db_manager_get_sql_file ("sqlite-stored-procs.sql");
@@ -69,7 +69,7 @@
return FALSE;
}
- g_message ("Loaded prepared queries file:'%s' size:%" G_GSIZE_FORMAT " bytes",
+ g_message ("Loaded prepared queries file:'%s' size:%" G_GSIZE_FORMAT " bytes",
sql_filename,
g_mapped_file_get_length (mapped_file));
@@ -95,8 +95,8 @@
g_message (" Adding query:'%s'", details[0]);
- g_hash_table_insert (prepared_queries,
- g_strdup (details[0]),
+ g_hash_table_insert (prepared_queries,
+ g_strdup (details[0]),
g_strdup (details[1]));
g_strfreev (details);
}
@@ -854,18 +854,122 @@
g_free (path);
}
+static void
+load_metadata_file (TrackerDBInterface *iface,
+ const gchar *filename)
+{
+ GKeyFile *key_file = NULL;
+ gchar *service_file, *str_id;
+ gchar **groups, **keys;
+ TrackerField *def;
+ gint id, i, j;
+
+ key_file = g_key_file_new ();
+ service_file = tracker_db_manager_get_service_file (filename);
+
+ if (!g_key_file_load_from_file (key_file, service_file, G_KEY_FILE_NONE, NULL)) {
+ g_free (service_file);
+ g_key_file_free (key_file);
+ return;
+ }
+
+ groups = g_key_file_get_groups (key_file, NULL);
+
+ for (i = 0; groups[i]; i++) {
+ def = tracker_ontology_get_field_def (groups[i]);
+
+ if (!def) {
+ tracker_db_interface_execute_procedure (iface, NULL, "InsertMetadataType", groups[i], NULL);
+ id = tracker_db_interface_sqlite_get_last_insert_id (TRACKER_DB_INTERFACE_SQLITE (iface));
+ } else {
+ id = atoi (tracker_field_get_id (def));
+ g_error ("Duplicated metadata description %s", groups[i]);
+ }
+
+ str_id = tracker_uint_to_string (id);
+ keys = g_key_file_get_keys (key_file, groups[i], NULL, NULL);
+
+ for (j = 0; keys[j]; j++) {
+ gchar *value, *new_value;
+
+ value = g_key_file_get_locale_string (key_file, groups[i], keys[j], NULL, NULL);
+
+ if (!value) {
+ continue;
+ }
+
+ new_value = tracker_boolean_as_text_to_number (value);
+ g_free (value);
+
+ if (strcasecmp (keys[j], "Parent") == 0) {
+ tracker_db_interface_execute_procedure (iface, NULL, "InsertMetaDataChildren",
+ str_id, new_value, NULL);
+ } else if (strcasecmp (keys[j], "DataType") == 0) {
+ GEnumValue *enum_value;
+
+ enum_value = g_enum_get_value_by_name (g_type_class_peek (TRACKER_TYPE_FIELD_TYPE), new_value);
+
+ if (enum_value) {
+ tracker_db_interface_execute_query (iface, NULL,
+ "update MetaDataTypes set DataTypeID = %d where ID = %d",
+ enum_value->value, id);
+ }
+ } else {
+ char *esc_value = tracker_escape_string (new_value);
+
+ tracker_db_interface_execute_query (iface, NULL,
+ "update MetaDataTypes set %s = '%s' where ID = %d",
+ keys[j], esc_value, id);
+ g_free (esc_value);
+ }
+
+ g_free (new_value);
+ }
+
+ g_free (str_id);
+ g_strfreev (keys);
+ }
+
+ g_strfreev (groups);
+ g_free (service_file);
+ g_key_file_free (key_file);
+}
+
TrackerDBInterface *
tracker_indexer_db_get_common (void)
{
TrackerDBInterface *interface;
- const gchar *common_db_path;
+ const gchar *path;
+ gboolean create = FALSE;
+
+ path = tracker_db_manager_get_file (TRACKER_DB_COMMON);
+
+ if (!g_file_test (path, G_FILE_TEST_EXISTS)) {
+ create = TRUE;
+ }
- common_db_path = tracker_db_manager_get_file (TRACKER_DB_COMMON);
- interface = tracker_db_interface_sqlite_new (common_db_path);
+ interface = tracker_db_interface_sqlite_new (path);
tracker_db_interface_set_procedure_table (interface, prepared_queries);
- /* Load services info */
- load_service_file (interface, "default.service");
+ if (create) {
+ /* Create tables */
+ load_sql_file (interface, "sqlite-tracker.sql", NULL);
+ load_sql_file (interface, "sqlite-metadata.sql", NULL);
+ load_sql_file (interface, "sqlite-service-types.sql", NULL);
+
+ /* Load services info */
+ load_service_file (interface, "default.service");
+
+ /* Load metadata info */
+ load_metadata_file (interface, "default.metadata");
+ load_metadata_file (interface, "file.metadata");
+ load_metadata_file (interface, "audio.metadata");
+ load_metadata_file (interface, "application.metadata");
+ load_metadata_file (interface, "document.metadata");
+ load_metadata_file (interface, "email.metadata");
+ load_metadata_file (interface, "image.metadata");
+ load_metadata_file (interface, "video.metadata");
+ }
/* Load static data into tracker ontology */
tracker_db_get_static_data (interface);
@@ -897,7 +1001,6 @@
if (create) {
load_sql_file (interface, "sqlite-service.sql", NULL);
load_sql_file (interface, "sqlite-service-triggers.sql", "!");
- load_sql_file (interface, "sqlite-metadata.sql", NULL);
}
return interface;
Modified: branches/xesam-support/src/trackerd/Makefile.am
==============================================================================
--- branches/xesam-support/src/trackerd/Makefile.am (original)
+++ branches/xesam-support/src/trackerd/Makefile.am Mon Jun 2 18:57:26 2008
@@ -17,22 +17,10 @@
$(GTHREAD_CFLAGS) \
$(GLIB2_CFLAGS)
-if HAVE_INOTIFY
-watch_sources = \
- linux-inotify-syscalls.h \
- tracker-inotify.c
-else
-if HAVE_FAM
-watch_sources = tracker-fam.c
-else
-if OS_WIN32
-watch_sources = tracker-win-fs-changes.c
-else
-watch_sources = tracker-poll.c
-endif
-endif
-endif
+#
+# Mail sources
+#
mail_modulesdir = $(libdir)/tracker/mail-modules
mail_modules_LTLIBRARIES = \
libemail-evolution.la \
@@ -59,14 +47,32 @@
libemail_kmail_la_LIBADD = $(GLIB2_LIBS)
+#
+# Use either inotify, fam, win32 or poll API to know about file
+# changes and in that order.
+#
+if HAVE_INOTIFY
+watcher_sources = tracker-watcher-inotify.c linux-inotify-syscalls.h
+else # HAVE_INOTIFY
+if HAVE_FAM
+watcher_sources = tracker-watcher-fam.c
+else # HAVE_FAM
+if OS_WIN32
+watcher_sources = tracker-watcher-win.c
+else # OS_WIN32
+watcher_sources = tracker-watcher-poll.c
+endif # OS_WIN32
+endif # HAVE_FAM
+endif # HAVE_INOTIFY
+
+
+#
+# Daemon sources
+#
bin_PROGRAMS = trackerd
trackerd_SOURCES = \
- $(watch_sources) \
- $(win_sources) \
- $(unix_sources) \
- tracker-cache.c \
- tracker-cache.h \
+ $(watcher_sources) \
tracker-daemon.c \
tracker-daemon.h \
tracker-db.c \
@@ -89,13 +95,13 @@
tracker-indexer.h \
tracker-index-stage.c \
tracker-index-stage.h \
+ tracker-process-files.c \
+ tracker-process-files.h \
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 \
tracker-query-tree.h \
tracker-rdf-query.c \
Modified: branches/xesam-support/src/trackerd/tracker-db-email.c
==============================================================================
--- branches/xesam-support/src/trackerd/tracker-db-email.c (original)
+++ branches/xesam-support/src/trackerd/tracker-db-email.c Mon Jun 2 18:57:26 2008
@@ -665,7 +665,6 @@
}
}
- tracker_db_update_indexes_for_new_service (id, type_id, index_table);
tracker_parser_text_free (index_table);
g_free (str_id);
Modified: branches/xesam-support/src/trackerd/tracker-db-sqlite.c
==============================================================================
--- branches/xesam-support/src/trackerd/tracker-db-sqlite.c (original)
+++ branches/xesam-support/src/trackerd/tracker-db-sqlite.c Mon Jun 2 18:57:26 2008
@@ -41,12 +41,12 @@
#include "tracker-db-sqlite.h"
#include "tracker-indexer.h"
-#include "tracker-cache.h"
#include "tracker-main.h"
#include "tracker-utils.h"
-#include "tracker-watch.h"
+#include "tracker-watcher.h"
#include "tracker-query-tree.h"
#include "tracker-xesam-ontology.h"
+#include "tracker-xesam-manager.h"
#define MAX_INDEX_TEXT_LENGTH 1048576
#define MAX_TEXT_BUFFER 65567
@@ -2298,7 +2298,9 @@
/* we only do differential updates so only changed words scores are updated */
sid = tracker_ontology_get_id_for_service_type (service);
+#if 0
tracker_db_update_differential_index (old_table, new_table, id, sid);
+#endif
tracker_parser_text_free (old_table);
tracker_parser_text_free (new_table);
@@ -3509,6 +3511,8 @@
g_free (eid);
+ tracker_xesam_manager_wakeup (NULL);
+
return id;
}
@@ -4275,19 +4279,17 @@
static inline void
-move_directory (DBConnection *db_con, const char *moved_from_uri, const char *moved_to_uri)
+move_directory (DBConnection *db_con,
+ const gchar *moved_from_uri,
+ const gchar *moved_to_uri)
{
-
/* stop watching old dir, start watching new dir */
- tracker_remove_watch_dir (moved_from_uri, TRUE, db_con);
+ tracker_watcher_remove_dir (moved_from_uri, TRUE, db_con);
tracker_db_move_file (db_con, moved_from_uri, moved_to_uri);
move_directory_files (db_con, moved_from_uri, moved_to_uri);
- if (tracker_count_watch_dirs () < (int) tracker->watch_limit) {
- tracker_add_watch_dir (moved_to_uri, db_con);
- }
-
+ tracker_watcher_add_dir (moved_to_uri, db_con);
}
@@ -4363,121 +4365,6 @@
return result_set;
}
-static void
-append_index_data (gpointer key,
- gpointer value,
- gpointer user_data)
-{
- char *word;
- int score;
- ServiceTypeInfo *info;
-
- word = (char *) key;
- score = GPOINTER_TO_INT (value);
- info = user_data;
-
- if (score != 0) {
- /* cache word update */
- tracker_cache_add (word, info->service_id, info->service_type_id, score, TRUE);
- }
-
-
-}
-
-
-static void
-update_index_data (gpointer key,
- gpointer value,
- gpointer user_data)
-{
- char *word;
- int score;
- ServiceTypeInfo *info;
-
- word = (char *) key;
- score = GPOINTER_TO_INT (value);
- info = user_data;
-
- if (score == 0) return;
-
- g_debug ("Updating index for word %s with score %d", word, score);
-
- tracker_cache_add (word, info->service_id, info->service_type_id, score, FALSE);
-
-}
-
-
-void
-tracker_db_update_indexes_for_new_service (guint32 service_id, int service_type_id, GHashTable *table)
-{
-
- if (table) {
- ServiceTypeInfo *info;
-
- info = g_slice_new (ServiceTypeInfo);
-
- info->service_id = service_id;
- info->service_type_id = service_type_id;
-
- g_hash_table_foreach (table, append_index_data, info);
- g_slice_free (ServiceTypeInfo, info);
- }
-}
-
-
-
-
-
-static void
-cmp_data (gpointer key,
- gpointer value,
- gpointer user_data)
-{
- char *word;
- int score;
- GHashTable *new_table;
-
- gpointer k=0,v=0;
-
- word = (char *) key;
- score = GPOINTER_TO_INT (value);
- new_table = user_data;
-
- if (!g_hash_table_lookup_extended (new_table, word, &k, &v)) {
- g_hash_table_insert (new_table, g_strdup (word), GINT_TO_POINTER (0 - score));
- } else {
- g_hash_table_insert (new_table, (char *) word, GINT_TO_POINTER (GPOINTER_TO_INT (v) - score));
- }
-}
-
-
-void
-tracker_db_update_differential_index (GHashTable *old_table, GHashTable *new_table, const char *id, int service_type_id)
-{
- ServiceTypeInfo *info;
-
- g_return_if_fail (id || service_type_id > -1);
-
- if (!new_table) {
- new_table = g_hash_table_new (g_str_hash, g_str_equal);
- }
-
- /* calculate the differential word scores between old and new data*/
- if (old_table) {
- g_hash_table_foreach (old_table, cmp_data, new_table);
- }
-
- info = g_new (ServiceTypeInfo, 1);
-
- info->service_id = strtoul (id, NULL, 10);
- info->service_type_id = service_type_id;
-
- g_hash_table_foreach (new_table, update_index_data, info);
-
- g_free (info);
-}
-
-
TrackerDBResultSet *
tracker_db_get_keyword_list (DBConnection *db_con, const char *service)
{
Modified: branches/xesam-support/src/trackerd/tracker-db.c
==============================================================================
--- branches/xesam-support/src/trackerd/tracker-db.c (original)
+++ branches/xesam-support/src/trackerd/tracker-db.c Mon Jun 2 18:57:26 2008
@@ -1006,12 +1006,14 @@
tracker_db_save_metadata (db_con, meta_table, index_table, service, info->file_id, info->is_new);
}
+#if 0
/* 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 {
tracker_db_update_differential_index (old_table, index_table, str_file_id, info->service_type_id);
}
+#endif
tracker_parser_text_free (index_table);
tracker_parser_text_free (old_table);
Modified: branches/xesam-support/src/trackerd/tracker-dbus.c
==============================================================================
--- branches/xesam-support/src/trackerd/tracker-dbus.c (original)
+++ branches/xesam-support/src/trackerd/tracker-dbus.c Mon Jun 2 18:57:26 2008
@@ -39,7 +39,7 @@
#include "tracker-xesam-glue.h"
#include "tracker-indexer-client.h"
#include "tracker-utils.h"
-#include "tracker-watch.h"
+#include "tracker-watcher.h"
static DBusGConnection *connection;
static DBusGProxy *proxy;
Modified: branches/xesam-support/src/trackerd/tracker-email-evolution.c
==============================================================================
--- branches/xesam-support/src/trackerd/tracker-email-evolution.c (original)
+++ branches/xesam-support/src/trackerd/tracker-email-evolution.c Mon Jun 2 18:57:26 2008
@@ -41,10 +41,9 @@
#include "tracker-email-utils.h"
#include "tracker-db-email.h"
-#include "tracker-cache.h"
#include "tracker-dbus.h"
#include "tracker-daemon.h"
-#include "tracker-watch.h"
+#include "tracker-watcher.h"
#include "tracker-status.h"
#include "tracker-utils.h"
#include "tracker-main.h"
@@ -1447,6 +1446,7 @@
email_free_mail_file (mail_msg->parent_mail_file);
email_free_mail_message (mail_msg);
+#if 0
if (!tracker_cache_process_events (db_con->data, TRUE)) {
tracker->shutdown = TRUE;
tracker_status_set_and_signal (TRACKER_STATUS_SHUTDOWN,
@@ -1458,6 +1458,7 @@
tracker_config_get_enable_indexing (tracker->config));
return;
}
+#endif
if (tracker_db_regulate_transactions (db_con->data, 500)) {
if (tracker_config_get_verbosity (tracker->config) == 1) {
Modified: branches/xesam-support/src/trackerd/tracker-email-kmail.c
==============================================================================
--- branches/xesam-support/src/trackerd/tracker-email-kmail.c (original)
+++ branches/xesam-support/src/trackerd/tracker-email-kmail.c Mon Jun 2 18:57:26 2008
@@ -33,8 +33,9 @@
#include "tracker-email-utils.h"
#include "tracker-db-email.h"
-#include "tracker-watch.h"
+#include "tracker-main.h"
#include "tracker-process-files.h"
+#include "tracker-watcher.h"
typedef struct {
gchar *imap_path;
@@ -652,7 +653,7 @@
dirs = NULL;
tmp_dirs = NULL;
- tracker_process_files_get_all_dirs (tracker, dir_path, &tmp_dirs);
+ tracker_process_files_get_all_dirs (dir_path, &tmp_dirs);
for (dir = tmp_dirs; dir; dir = dir->next) {
gchar *dir_path = g_unescape_uri_string (dir->data, "");
@@ -662,7 +663,7 @@
(( in_imap_dir && dir_name[0] == '.' && g_str_has_suffix (dir_name, ".directory")) ||
!in_imap_dir )
) {
- if (!tracker_is_directory_watched (dir_path, db_con)) {
+ if (!tracker_watcher_is_dir_watched (dir_path, db_con)) {
/* if we are in a maildir directory, we will only index emails in directory "cur" */
gchar *dir_cur = g_build_filename (dir_path, "cur", NULL);
Modified: branches/xesam-support/src/trackerd/tracker-email-modest.c
==============================================================================
--- branches/xesam-support/src/trackerd/tracker-email-modest.c (original)
+++ branches/xesam-support/src/trackerd/tracker-email-modest.c Mon Jun 2 18:57:26 2008
@@ -41,9 +41,8 @@
#include "tracker-db-email.h"
#include "tracker-dbus.h"
#include "tracker-daemon.h"
-#include "tracker-cache.h"
#include "tracker-status.h"
-#include "tracker-watch.h"
+#include "tracker-watcher.h"
#define MODEST_HOME ".modest"
@@ -934,6 +933,15 @@
email_free_mail_file (mail_msg->parent_mail_file);
email_free_mail_message (mail_msg);
+#if 0
+ /* FIXME-indexer-split: This has been
+ * commented out as a result of
+ * removing the tracker-cache.[ch] which
+ * is no longer used. This code is in a
+ * transitional period.
+ *
+ * -Martyn
+ */
if (!tracker_cache_process_events (db_con->data, TRUE)) {
tracker->shutdown = TRUE;
tracker_status_set_and_signal (TRACKER_STATUS_SHUTDOWN,
@@ -945,6 +953,7 @@
tracker_config_get_enable_indexing (tracker->config));
return;
}
+#endif
if (tracker_db_regulate_transactions (db_con->data, 500)) {
Modified: branches/xesam-support/src/trackerd/tracker-email-thunderbird.c
==============================================================================
--- branches/xesam-support/src/trackerd/tracker-email-thunderbird.c (original)
+++ branches/xesam-support/src/trackerd/tracker-email-thunderbird.c Mon Jun 2 18:57:26 2008
@@ -28,7 +28,7 @@
#include <libtracker-common/tracker-config.h>
#include "tracker-db-email.h"
-#include "tracker-watch.h"
+#include "tracker-watcher.h"
#include "tracker-main.h"
typedef enum
Modified: branches/xesam-support/src/trackerd/tracker-email-utils.c
==============================================================================
--- branches/xesam-support/src/trackerd/tracker-email-utils.c (original)
+++ branches/xesam-support/src/trackerd/tracker-email-utils.c Mon Jun 2 18:57:26 2008
@@ -35,12 +35,11 @@
#include <libtracker-common/tracker-type-utils.h>
#include <libtracker-common/tracker-utils.h>
-#include "tracker-cache.h"
#include "tracker-db-email.h"
#include "tracker-dbus.h"
#include "tracker-daemon.h"
#include "tracker-email-utils.h"
-#include "tracker-watch.h"
+#include "tracker-watcher.h"
extern Tracker *tracker;
@@ -177,10 +176,19 @@
email_free_mail_message (mail_msg);
+#if 0
+ /* FIXME-indexer-split: This has been commented out as
+ * a result of removing the tracker-cache.[ch] which
+ * is no longer used. This code is in a transitional
+ * period.
+ *
+ * -Martyn
+ */
if (!tracker_cache_process_events (db_con->data, TRUE) ) {
tracker->shutdown = TRUE;
return FALSE;
}
+#endif
if (tracker_db_regulate_transactions (db_con->data, 500)) {
GObject *object;
Modified: branches/xesam-support/src/trackerd/tracker-indexer.c
==============================================================================
--- branches/xesam-support/src/trackerd/tracker-indexer.c (original)
+++ branches/xesam-support/src/trackerd/tracker-indexer.c Mon Jun 2 18:57:26 2008
@@ -50,7 +50,6 @@
#include "tracker-query-tree.h"
#include "tracker-indexer.h"
-#include "tracker-cache.h"
#include "tracker-dbus.h"
#include "tracker-daemon.h"
#include "tracker-process-files.h"
@@ -328,10 +327,6 @@
int num, b_count;
- if (tracker->shutdown) {
- return FALSE;
- }
-
/* set bucket count to bucket_ratio times no. of recs divided by no. of divisions */
num = CLAMP (get_preferred_bucket_count (indexer),
tracker_config_get_min_bucket_count (tracker->config),
@@ -434,9 +429,18 @@
i++;
if (i > 1 && (i % 200 == 0)) {
+#if 0
+ /* FIXME-indexer-split: This has been commented out as
+ * a result of removing the tracker-cache.[ch] which
+ * is no longer used. This code is in a transitional
+ * period.
+ *
+ * -Martyn
+ */
if (!tracker_cache_process_events (NULL, FALSE)) {
return;
}
+#endif
}
if (i > 1 && (i % interval == 0)) {
@@ -498,12 +502,10 @@
if (type == INDEX_TYPE_FILES) {
- files = tracker_process_files_get_files_with_prefix (tracker,
- tracker_get_data_dir (),
+ files = tracker_process_files_get_files_with_prefix (tracker_get_data_dir (),
"file-index.tmp.");
} else {
- files = tracker_process_files_get_files_with_prefix (tracker,
- tracker_get_data_dir (),
+ files = tracker_process_files_get_files_with_prefix (tracker_get_data_dir (),
"email-index.tmp.");
}
@@ -531,13 +533,11 @@
data_dir = tracker_get_data_dir ();
if (type == INDEX_TYPE_FILES) {
- files = tracker_process_files_get_files_with_prefix (tracker,
- data_dir,
+ files = tracker_process_files_get_files_with_prefix (data_dir,
"file-index.tmp.");
final = g_build_filename (data_dir, "file-index-final", NULL);
} else {
- files = tracker_process_files_get_files_with_prefix (tracker,
- data_dir,
+ files = tracker_process_files_get_files_with_prefix (data_dir,
"email-index.tmp.");
final = g_build_filename (data_dir, "email-index-final", NULL);
}
@@ -609,10 +609,6 @@
gboolean final_exists;
gchar *tmp;
- if (tracker->shutdown) {
- return;
- }
-
data_dir = tracker_get_data_dir ();
object = tracker_dbus_get_object (TRACKER_TYPE_DAEMON);
@@ -636,7 +632,7 @@
g_free (tmp);
}
- file_list = tracker_process_files_get_files_with_prefix (tracker, data_dir, prefix);
+ file_list = tracker_process_files_get_files_with_prefix (data_dir, prefix);
if (!file_list || !file_list->data) {
g_slist_free (index_list);
@@ -738,6 +734,14 @@
i++;
if (i > 101 && (i % 100 == 0)) {
+#if 0
+ /* FIXME-indexer-split: This has been commented out as
+ * a result of removing the tracker-cache.[ch] which
+ * is no longer used. This code is in a transitional
+ * period.
+ *
+ * -Martyn
+ */
if (!tracker_cache_process_events (NULL, FALSE)) {
tracker_status_set_and_signal (TRACKER_STATUS_SHUTDOWN,
tracker->first_time_index,
@@ -748,6 +752,7 @@
tracker_config_get_enable_indexing (tracker->config));
return;
}
+#endif
}
if (i > interval && (i % interval == 0)) {
@@ -889,10 +894,6 @@
gboolean
tracker_indexer_append_word_chunk (Indexer *indexer, const gchar *word, WordDetails *details, gint word_detail_count)
{
- if (tracker->shutdown) {
- return FALSE;
- }
-
g_return_val_if_fail (indexer, FALSE);
g_return_val_if_fail (indexer->word_index, FALSE);
g_return_val_if_fail (word, FALSE);
Modified: branches/xesam-support/src/trackerd/tracker-main.c
==============================================================================
--- branches/xesam-support/src/trackerd/tracker-main.c (original)
+++ branches/xesam-support/src/trackerd/tracker-main.c Mon Jun 2 18:57:26 2008
@@ -46,12 +46,11 @@
#include <libtracker-db/tracker-db-manager.h>
#include "tracker-email.h"
-#include "tracker-cache.h"
#include "tracker-dbus.h"
#include "tracker-indexer.h"
#include "tracker-process-files.h"
#include "tracker-status.h"
-#include "tracker-watch.h"
+#include "tracker-watcher.h"
#include "tracker-xesam-manager.h"
#ifdef OS_WIN32
@@ -403,6 +402,15 @@
}
+static gboolean
+shutdown_timeout_cb (gpointer user_data)
+{
+ g_critical ("Could not exit in a timely fashion - terminating...");
+ exit (EXIT_FAILURE);
+
+ return FALSE;
+}
+
static void
signal_handler (gint signo)
{
@@ -426,14 +434,8 @@
case SIGTERM:
case SIGINT:
in_loop = TRUE;
-
tracker->is_running = FALSE;
- tracker_end_watching ();
-
- g_timeout_add_full (G_PRIORITY_LOW, 1,
- (GSourceFunc) tracker_shutdown,
- g_strdup (g_strsignal (signo)), NULL);
-
+
default:
if (g_strsignal (signo)) {
g_message ("Received signal:%d->'%s'",
@@ -659,15 +661,6 @@
tracker_db_get_static_data (db_con);
}
-static gboolean
-shutdown_timeout_cb (gpointer user_data)
-{
- g_critical ("Could not exit in a timely fashion - terminating...");
- exit (EXIT_FAILURE);
-
- return FALSE;
-}
-
static void
shutdown_threads (GThread *thread_to_join)
{
@@ -854,7 +847,6 @@
g_option_context_add_main_entries (context, entries, NULL);
g_option_context_parse (context, &argc, &argv, &error);
-
g_option_context_free (context);
g_free (example);
@@ -940,11 +932,15 @@
sanity_check_option_values ();
+ if (!tracker_watcher_init ()) {
+ return EXIT_FAILURE;
+ }
+
tracker_nfs_lock_init (tracker_config_get_nfs_locking (tracker->config));
+ tracker_watcher_init ();
tracker_db_init ();
tracker_db_manager_init (data_dir, user_data_dir, sys_tmp_dir);
tracker_xesam_manager_init ();
- tracker_cache_init ();
tracker_ontology_init ();
tracker_email_init (tracker->config);
@@ -977,11 +973,9 @@
}
if (!tracker->readonly) {
- if (!tracker_start_watching ()) {
- tracker->is_running = FALSE;
- g_critical ("File monitoring failed to start");
- }
- else if (tracker_config_get_enable_indexing (tracker->config)) {
+ tracker_process_files_init (tracker);
+
+ if (tracker_config_get_enable_indexing (tracker->config)) {
gint initial_sleep;
initial_sleep = tracker_config_get_initial_sleep (tracker->config);
@@ -993,12 +987,12 @@
initial_sleep --;
- if (!tracker->is_running || tracker->shutdown) {
+ if (!tracker->is_running) {
break;
}
}
- if (tracker->is_running && !tracker->shutdown) {
+ if (tracker->is_running) {
DBusGProxy *proxy;
g_message ("Indexing enabled, starting...");
proxy = tracker_dbus_start_indexer ();
@@ -1031,7 +1025,6 @@
/*
* Shutdown the daemon
*/
- tracker->shutdown = TRUE;
tracker_status_set (TRACKER_STATUS_SHUTDOWN);
/* Reset black list files */
@@ -1040,7 +1033,7 @@
g_slist_free (l);
/* Set kill timeout */
- g_timeout_add_full (G_PRIORITY_LOW, 20000, shutdown_timeout_cb, NULL, NULL);
+ g_timeout_add_full (G_PRIORITY_LOW, 10000, shutdown_timeout_cb, NULL, NULL);
shutdown_indexer ();
shutdown_databases ();
@@ -1048,13 +1041,14 @@
shutdown_directories ();
/* Shutdown major subsystems */
+ tracker_process_files_shutdown ();
tracker_email_shutdown ();
tracker_dbus_shutdown ();
tracker_ontology_shutdown ();
- tracker_cache_shutdown ();
tracker_xesam_manager_shutdown ();
tracker_db_shutdown ();
tracker_db_manager_shutdown ();
+ tracker_watcher_shutdown ();
tracker_nfs_lock_shutdown ();
tracker_log_shutdown ();
Modified: branches/xesam-support/src/trackerd/tracker-main.h
==============================================================================
--- branches/xesam-support/src/trackerd/tracker-main.h (original)
+++ branches/xesam-support/src/trackerd/tracker-main.h Mon Jun 2 18:57:26 2008
@@ -46,23 +46,23 @@
G_BEGIN_DECLS
typedef struct {
- gboolean is_running;
- gboolean readonly;
+ gboolean is_running;
+ gboolean readonly;
- gint pid;
+ gint pid;
- gboolean reindex;
+ gboolean reindex;
#ifdef HAVE_HAL
- TrackerHal *hal;
+ TrackerHal *hal;
#endif
- TrackerConfig *config;
- TrackerLanguage *language;
+ TrackerConfig *config;
+ TrackerLanguage *language;
/* Config options */
- guint32 watch_limit;
+ guint32 watch_limit;
/* Performance and memory usage options */
gint max_process_queue_size;
@@ -70,7 +70,6 @@
gint memory_limit;
/* Pause/shutdown */
- gboolean shutdown;
gboolean pause_manual;
gboolean pause_battery;
gboolean pause_io;
@@ -88,8 +87,6 @@
gint mbox_count;
gint mbox_processed;
- gint grace_period;
-
/* Email config options */
gint email_service_min;
gint email_service_max;
Modified: branches/xesam-support/src/trackerd/tracker-process-files.c
==============================================================================
--- branches/xesam-support/src/trackerd/tracker-process-files.c (original)
+++ branches/xesam-support/src/trackerd/tracker-process-files.c Mon Jun 2 18:57:26 2008
@@ -44,25 +44,28 @@
#include "tracker-db.h"
#include "tracker-dbus.h"
#include "tracker-daemon.h"
-#include "tracker-cache.h"
#include "tracker-email.h"
#include "tracker-indexer.h"
-#include "tracker-watch.h"
+#include "tracker-watcher.h"
#include "tracker-status.h"
#include "tracker-process-files.h"
-static GAsyncQueue *dir_queue;
-static GAsyncQueue *file_metadata_queue;
-static GAsyncQueue *file_process_queue;
-
-static GSList *ignore_pattern_list;
-static GSList *temp_black_list;
-static GSList *crawl_directories;
+static TrackerHal *hal;
+static TrackerConfig *config;
+
+static DBConnection *db_con;
+
+static GAsyncQueue *dir_queue;
+static GAsyncQueue *file_metadata_queue;
+static GAsyncQueue *file_process_queue;
+
+static GSList *ignore_pattern_list;
+static GSList *temp_black_list;
+static GSList *crawl_directories;
-static gchar **ignore_pattern;
-static GTimer *index_duration;
+static gchar **ignore_pattern;
-static const gchar *ignore_suffix[] = {
+static const gchar *ignore_suffix[] = {
"~", ".o", ".la", ".lo", ".loT", ".in",
".csproj", ".m4", ".rej", ".gmo", ".orig",
".pc", ".omf", ".aux", ".tmp", ".po",
@@ -70,12 +73,12 @@
".part", NULL
};
-static const gchar *ignore_prefix[] = {
+static const gchar *ignore_prefix[] = {
"autom4te", "conftest.", "confstat",
"config.", NULL
};
-static const gchar *ignore_name[] = {
+static const gchar *ignore_name[] = {
"po", "CVS", "aclocal", "Makefile", "CVS",
"SCCS", "ltmain.sh","libtool", "config.status",
"conftest", "confdefs.h", NULL
@@ -102,8 +105,7 @@
}
static GSList *
-process_get_files (Tracker *tracker,
- const char *dir,
+process_get_files (const char *dir,
gboolean dir_only,
gboolean skip_ignored_files,
const char *filter_prefix)
@@ -129,12 +131,6 @@
gchar *filename;
gchar *built_filename;
- if (!tracker->is_running) {
- g_free (dir_in_locale);
- g_dir_close (dirp);
- return NULL;
- }
-
filename = g_filename_to_utf8 (name, -1, NULL, NULL, NULL);
if (!filename) {
@@ -160,13 +156,13 @@
continue;
}
- if (!tracker_process_files_should_be_crawled (tracker, built_filename)) {
+ if (!tracker_process_files_should_be_crawled (built_filename)) {
g_free (built_filename);
continue;
}
if (!dir_only || tracker_file_is_directory (built_filename)) {
- if (tracker_process_files_should_be_watched (tracker->config, built_filename)) {
+ if (tracker_process_files_should_be_watched (config, built_filename)) {
files = g_slist_prepend (files, built_filename);
} else {
g_free (built_filename);
@@ -181,26 +177,16 @@
g_free (dir_in_locale);
- if (!tracker->is_running) {
- if (files) {
- g_slist_foreach (files, (GFunc) g_free, NULL);
- g_slist_free (files);
- }
-
- return NULL;
- }
-
return files;
}
static void
-process_get_directories (Tracker *tracker,
- const char *dir,
+process_get_directories (const char *dir,
GSList **files)
{
GSList *l;
- l = process_get_files (tracker, dir, TRUE, TRUE, NULL);
+ l = process_get_files (dir, TRUE, TRUE, NULL);
if (*files) {
*files = g_slist_concat (*files, l);
@@ -210,16 +196,11 @@
}
static void
-process_watch_directories (Tracker *tracker,
- GSList *dirs,
+process_watch_directories (GSList *dirs,
DBConnection *db_con)
{
GSList *list;
-
- if (!tracker->is_running) {
- return;
- }
-
+
/* Add sub directories breadth first recursively to avoid
* running out of file handles.
*/
@@ -231,7 +212,6 @@
for (l = list; l; l = l->next) {
gchar *dir;
- guint watches;
if (!l->data) {
continue;
@@ -258,28 +238,24 @@
continue;
}
- if (!tracker_process_files_should_be_watched (tracker->config, dir) ||
- !tracker_process_files_should_be_watched (tracker->config, dir)) {
+ if (!tracker_process_files_should_be_watched (config, dir) ||
+ !tracker_process_files_should_be_watched (config, dir)) {
continue;
}
crawl_directories = g_slist_prepend (crawl_directories, dir);
- if (!tracker_config_get_enable_watches (tracker->config)) {
+ if (!tracker_config_get_enable_watches (config)) {
continue;
}
- watches = tracker_count_watch_dirs () + g_slist_length (list);
-
- if (watches < tracker->watch_limit) {
- if (!tracker_add_watch_dir (dir, db_con)) {
- g_warning ("Watch failed for:'%s'", dir);
- }
+ if (!tracker_watcher_add_dir (dir, db_con)) {
+ g_warning ("Watch failed for:'%s'", dir);
}
}
for (l = list; l; l = l->next) {
- process_get_directories (tracker, l->data, &files);
+ process_get_directories (l->data, &files);
}
/* Don't free original list */
@@ -292,50 +268,36 @@
}
}
-typedef struct {
- Tracker *tracker;
- DBConnection *db_con;
-} ForEachDBCon;
-
static void
process_schedule_directory_check_foreach (const gchar *uri,
- ForEachDBCon *info)
+ DBConnection *db_con)
{
- if (!info->tracker->is_running) {
- return;
- }
-
-
- tracker_db_insert_pending_file (info->db_con, 0, uri, NULL, "unknown", 0,
- TRACKER_DB_ACTION_DIRECTORY_REFRESH, TRUE, FALSE, -1);
+ tracker_db_insert_pending_file (db_con, 0, uri, NULL, "unknown", 0,
+ TRACKER_DB_ACTION_DIRECTORY_REFRESH,
+ TRUE, FALSE, -1);
}
static void
process_schedule_file_check_foreach (const gchar *uri,
- ForEachDBCon *info)
+ DBConnection *db_con)
{
- if (!info->tracker->is_running) {
- return;
- }
-
g_return_if_fail (tracker_check_uri (uri));
- g_return_if_fail (info->db_con);
+ g_return_if_fail (db_con);
/* Keep mainloop responsive */
process_my_yield ();
if (!tracker_file_is_directory (uri)) {
- tracker_db_insert_pending_file (info->db_con, 0, uri, NULL, "unknown", 0,
+ tracker_db_insert_pending_file (db_con, 0, uri, NULL, "unknown", 0,
TRACKER_DB_ACTION_CHECK, 0, FALSE, -1);
} else {
- process_schedule_directory_check_foreach (uri, info);
+ process_schedule_directory_check_foreach (uri, db_con);
}
}
static inline void
-process_directory_list (Tracker *tracker,
- GSList *list,
- gboolean recurse,
+process_directory_list (GSList *list,
+ gboolean recurse,
DBConnection *db_con)
{
crawl_directories = NULL;
@@ -344,21 +306,16 @@
return;
}
- ForEachDBCon *info = g_slice_new (ForEachDBCon);
-
- info->db_con = db_con;
- info->tracker = tracker;
-
- process_watch_directories (tracker, list, db_con);
+ process_watch_directories (list, db_con);
g_slist_foreach (list,
(GFunc) process_schedule_directory_check_foreach,
- info);
+ db_con);
if (recurse && crawl_directories) {
g_slist_foreach (crawl_directories,
(GFunc) process_schedule_directory_check_foreach,
- info);
+ db_con);
}
if (crawl_directories) {
@@ -366,20 +323,13 @@
g_slist_free (crawl_directories);
crawl_directories = NULL;
}
- g_slice_free (ForEachDBCon, info);
}
static void
-process_scan_directory (Tracker *tracker,
- const gchar *uri,
+process_scan_directory (const gchar *uri,
DBConnection *db_con)
{
GSList *files;
- ForEachDBCon *info;
-
- if (!tracker->is_running) {
- return;
- }
g_return_if_fail (db_con);
g_return_if_fail (tracker_check_uri (uri));
@@ -388,17 +338,13 @@
/* Keep mainloop responsive */
process_my_yield ();
- files = process_get_files (tracker, uri, FALSE, TRUE, NULL);
+ files = process_get_files (uri, FALSE, TRUE, NULL);
g_message ("Scanning:'%s' for %d files", uri, g_slist_length (files));
- info = g_slice_new (ForEachDBCon);
- info->tracker = tracker;
- info->db_con = db_con;
-
g_slist_foreach (files,
(GFunc) process_schedule_file_check_foreach,
- info);
+ db_con);
g_slist_foreach (files,
(GFunc) g_free,
@@ -408,158 +354,13 @@
/* Recheck directory to update its mtime if its changed whilst
* scanning.
*/
-
-
- process_schedule_directory_check_foreach (uri, info);
-
- g_slice_free (ForEachDBCon, info);
+ process_schedule_directory_check_foreach (uri, db_con);
g_message ("Finished scanning");
}
static void
-process_action_verify (TrackerDBFileInfo *info)
-{
- /* Determines whether an action applies to a file or a
- * directory.
- */
-
- if (info->action == TRACKER_DB_ACTION_CHECK) {
- if (info->is_directory) {
- info->action = TRACKER_DB_ACTION_DIRECTORY_CHECK;
- info->counter = 0;
- } else {
- info->action = TRACKER_DB_ACTION_FILE_CHECK;
- }
-
- } else {
- if (info->action == TRACKER_DB_ACTION_DELETE || info->action == TRACKER_DB_ACTION_DELETE_SELF) {
-
- /* we are in trouble if we cant find the deleted uri in the DB - assume its a directory (worst case) */
- if (info->file_id == 0) {
- info->is_directory = TRUE;
- }
-
- info->counter = 0;
- if (info->is_directory) {
- info->action = TRACKER_DB_ACTION_DIRECTORY_DELETED;
- } else {
- info->action = TRACKER_DB_ACTION_FILE_DELETED;
- }
- } else {
- if (info->action == TRACKER_DB_ACTION_MOVED_FROM) {
- info->counter = 1;
- if (info->is_directory) {
- info->action = TRACKER_DB_ACTION_DIRECTORY_MOVED_FROM;
- } else {
- info->action = TRACKER_DB_ACTION_FILE_MOVED_FROM;
- }
-
- } else {
-
- if (info->action == TRACKER_DB_ACTION_CREATE) {
- if (info->is_directory) {
- info->action = TRACKER_DB_ACTION_DIRECTORY_CREATED;
- info->counter = 0; /* do not reschedule a created directory */
- } else {
- info->action = TRACKER_DB_ACTION_FILE_CREATED;
- }
-
- } else {
- if (info->action == TRACKER_DB_ACTION_FILE_MOVED_TO) {
- info->counter = 0;
- if (info->is_directory) {
- info->action = TRACKER_DB_ACTION_DIRECTORY_MOVED_TO;
- } else {
- info->action = TRACKER_DB_ACTION_FILE_MOVED_TO;
- }
- }
- }
- }
- }
- }
-}
-
-static void
-process_index_entity (Tracker *tracker,
- TrackerDBFileInfo *info,
- DBConnection *db_con)
-{
- TrackerService *def;
- gchar *service_info;
-
- g_return_if_fail (info);
- g_return_if_fail (tracker_check_uri (info->uri));
-
- if (!tracker_file_is_valid (info->uri)) {
- return;
- }
-
- if (!info->is_directory) {
- /* Sleep to throttle back indexing */
- tracker_throttle (100);
- }
-
- service_info = tracker_ontology_get_service_type_for_dir (info->uri);
-
- if (!service_info) {
- g_warning ("Can not find service for path:'%s'", info->uri);
- return;
- }
-
- def = tracker_ontology_get_service_type_by_name (service_info);
-
- if (!def) {
- if (service_info) {
- g_warning ("Unknown service:'%s'", service_info);
- } else {
- g_warning ("Unknown service");
- }
- g_free (service_info);
- return;
- }
-
- if (info->is_directory) {
- info->is_hidden = !tracker_service_get_show_service_directories (def);
- tracker_db_index_file (db_con, info, NULL, NULL);
- g_free (service_info);
- return;
- } else {
- info->is_hidden = !tracker_service_get_show_service_files (def);
- }
-
- if (g_str_has_suffix (service_info, "Emails")) {
- if (!tracker_email_index_file (db_con->emails, info)) {
- g_free (service_info);
- return;
- }
- } else if (strcmp (service_info, "Files") == 0) {
- tracker_db_index_file (db_con, info, NULL, NULL);
- } else if (strcmp (service_info, "WebHistory") ==0 ) {
- tracker_db_index_webhistory (db_con, info);
- } else if (g_str_has_suffix (service_info, "Conversations")) {
- tracker_db_index_conversation (db_con, info);
- } else if (strcmp (service_info, "Applications") == 0) {
-#if 0
- /* FIXME-indexer-split: This has been commented out as a
- * result of moving the tracker-apps.[ch] code to the indexer
- * directory. This code will be removed when this function is
- * updated to work correctly in the indexer application.
- *
- * -Martyn
- */
- tracker_db_index_application (db_con, info);
-#endif
- } else {
- tracker_db_index_service (db_con, info, NULL, NULL, NULL, FALSE, TRUE, TRUE, TRUE);
- }
-
- g_free (service_info);
-}
-
-static void
-process_index_delete_file (Tracker *tracker,
- TrackerDBFileInfo *info,
+process_index_delete_file (TrackerDBFileInfo *info,
DBConnection *db_con)
{
/* Info struct may have been deleted in transit here so check
@@ -580,8 +381,7 @@
}
static void
-process_index_delete_directory (Tracker *tracker,
- TrackerDBFileInfo *info,
+process_index_delete_directory (TrackerDBFileInfo *info,
DBConnection *db_con)
{
/* Info struct may have been deleted in transit here so check
@@ -598,14 +398,13 @@
tracker_db_delete_directory (db_con, info->file_id, info->uri);
- tracker_remove_watch_dir (info->uri, TRUE, db_con);
+ tracker_watcher_remove_dir (info->uri, TRUE, db_con);
g_message ("Deleting directory:'%s' and subdirs", info->uri);
}
static void
-process_index_delete_directory_check (Tracker *tracker,
- const gchar *uri,
+process_index_delete_directory_check (const gchar *uri,
DBConnection *db_con)
{
gchar **files;
@@ -628,9 +427,9 @@
info = tracker_db_get_file_info (db_con, info);
if (!info->is_directory) {
- process_index_delete_file (tracker, info, db_con);
+ process_index_delete_file (info, db_con);
} else {
- process_index_delete_directory (tracker, info, db_con);
+ process_index_delete_directory (info, db_con);
}
tracker_db_file_info_free (info);
}
@@ -643,90 +442,40 @@
process_queue_files_foreach (const gchar *uri,
gpointer user_data)
{
- Tracker *tracker;
TrackerDBFileInfo *info;
- tracker = (Tracker*) user_data;
info = tracker_db_file_info_new (uri, TRACKER_DB_ACTION_CHECK, 0, 0);
g_async_queue_push (file_process_queue, info);
}
static void
-process_check_directory (Tracker *tracker,
- const gchar *uri)
+process_check_directory (const gchar *uri)
{
GSList *files;
- if (!tracker->is_running) {
- return;
- }
-
g_return_if_fail (tracker_check_uri (uri));
g_return_if_fail (tracker_file_is_directory (uri));
- files = process_get_files (tracker, uri, FALSE, TRUE, NULL);
+ files = process_get_files (uri, FALSE, TRUE, NULL);
g_message ("Checking:'%s' for %d files", uri, g_slist_length (files));
- g_slist_foreach (files, (GFunc) process_queue_files_foreach, tracker);
+ g_slist_foreach (files, (GFunc) process_queue_files_foreach, NULL);
g_slist_foreach (files, (GFunc) g_free, NULL);
g_slist_free (files);
- process_queue_files_foreach (uri, tracker);
-
- if (tracker_index_stage_get () != TRACKER_INDEX_STAGE_EMAILS) {
- tracker->folders_processed++;
- }
-}
-
-/*
- * Actual Indexing functions
- */
-static void
-process_index_config (Tracker *tracker, DBConnection *db_con)
-{
- g_message ("Starting config indexing");
-}
-
-static void
-process_index_applications (Tracker *tracker, DBConnection *db_con)
-{
- GSList *list;
-
- g_message ("Starting application indexing");
-
- tracker_db_start_index_transaction (db_con);
- tracker_db_interface_start_transaction (db_con->cache->db);
-
-#if 0
- /* FIXME-indexer-split: This has been commented out as a
- * result of moving the tracker-apps.[ch] code to the indexer
- * directory. This code will be removed when this function is
- * updated to work correctly in the indexer application.
- *
- * -Martyn
- */
- tracker_applications_add_service_directories ();
-#endif
-
- list = tracker_ontology_get_dirs_for_service_type ("Applications");
- process_directory_list (tracker, list, FALSE, db_con);
-
- tracker_db_interface_end_transaction (db_con->cache->db);
-
- g_slist_free (list);
+ process_queue_files_foreach (uri, NULL);
}
static void
-process_index_get_remote_roots (Tracker *tracker,
- GSList **mounted_directory_roots,
- GSList **removable_device_roots)
+process_index_get_remote_roots (GSList **mounted_directory_roots,
+ GSList **removable_device_roots)
{
GSList *l1 = NULL;
GSList *l2 = NULL;
#ifdef HAVE_HAL
- l1 = tracker_hal_get_mounted_directory_roots (tracker->hal);
- l2 = tracker_hal_get_removable_device_roots (tracker->hal);
+ l1 = tracker_hal_get_mounted_directory_roots (hal);
+ l2 = tracker_hal_get_removable_device_roots (hal);
#endif /* HAVE_HAL */
/* The options to index removable media and the index mounted
@@ -757,8 +506,7 @@
}
static void
-process_index_get_roots (Tracker *tracker,
- GSList **included,
+process_index_get_roots (GSList **included,
GSList **excluded)
{
GSList *watch_directory_roots;
@@ -769,16 +517,15 @@
*included = NULL;
*excluded = NULL;
- process_index_get_remote_roots (tracker,
- &mounted_directory_roots,
+ process_index_get_remote_roots (&mounted_directory_roots,
&removable_device_roots);
/* Delete all stuff in the no watch dirs */
watch_directory_roots =
- tracker_config_get_watch_directory_roots (tracker->config);
+ tracker_config_get_watch_directory_roots (config);
no_watch_directory_roots =
- tracker_config_get_no_watch_directory_roots (tracker->config);
+ tracker_config_get_no_watch_directory_roots (config);
/* Create list for enabled roots based on config */
*included = g_slist_concat (*included, g_slist_copy (watch_directory_roots));
@@ -787,14 +534,14 @@
*excluded = g_slist_concat (*excluded, g_slist_copy (no_watch_directory_roots));
/* Add or remove roots which pertain to removable media */
- if (tracker_config_get_index_removable_devices (tracker->config)) {
+ if (tracker_config_get_index_removable_devices (config)) {
*included = g_slist_concat (*included, g_slist_copy (removable_device_roots));
} else {
*excluded = g_slist_concat (*excluded, g_slist_copy (removable_device_roots));
}
/* Add or remove roots which pertain to mounted directories */
- if (tracker_config_get_index_mounted_directories (tracker->config)) {
+ if (tracker_config_get_index_mounted_directories (config)) {
*included = g_slist_concat (*included, g_slist_copy (mounted_directory_roots));
} else {
*excluded = g_slist_concat (*excluded, g_slist_copy (mounted_directory_roots));
@@ -802,122 +549,11 @@
}
static void
-process_index_files (Tracker *tracker, DBConnection *db_con)
-{
- GObject *object;
- GSList *index_include;
- GSList *index_exclude;
- ForEachDBCon *info;
-
- g_message ("Starting file indexing...");
-
- object = tracker_dbus_get_object (TRACKER_TYPE_DAEMON);
-
- tracker_db_end_index_transaction (db_con);
-
- tracker->pause_io = FALSE;
-
- /* Signal state change */
- g_signal_emit_by_name (object,
- "index-state-change",
- tracker_status_get_as_string (),
- tracker->first_time_index,
- tracker->in_merge,
- tracker->pause_manual,
- tracker_should_pause_on_battery (),
- tracker->pause_io,
- tracker_config_get_enable_indexing (tracker->config));
-
- /* FIXME: Is this safe? shouldn't we free first? */
- crawl_directories = NULL;
-
- tracker_db_start_index_transaction (db_con);
-
- process_index_get_roots (tracker, &index_include, &index_exclude);
-
- if (index_exclude) {
- GSList *l;
-
- g_message ("Deleting entities where indexing is disabled or are not watched:");
-
- for (l = index_exclude; l; l = l->next) {
- guint32 id;
-
- g_message (" %s", (gchar*) l->data);
-
- id = tracker_db_get_file_id (db_con, l->data);
-
- if (id > 0) {
- tracker_db_delete_directory (db_con, id, l->data);
- }
- }
-
- g_slist_free (index_exclude);
- }
-
- if (!index_include) {
- g_message ("No directory roots to index!");
- return;
- }
-
- tracker_db_interface_start_transaction (db_con->cache->db);
-
- /* Index watched dirs first */
- process_watch_directories (tracker, index_include, db_con);
-
- info = g_slice_new (ForEachDBCon);
- info->tracker = tracker;
- info->db_con = db_con;
-
- g_slist_foreach (crawl_directories,
- (GFunc) process_schedule_directory_check_foreach,
- info);
-
- if (crawl_directories) {
- g_slist_foreach (crawl_directories,
- (GFunc) g_free,
- NULL);
- g_slist_free (crawl_directories);
- crawl_directories = NULL;
- }
-
- g_slist_foreach (index_include,
- (GFunc) process_schedule_directory_check_foreach,
- info);
-
- if (crawl_directories) {
- g_slist_foreach (crawl_directories,
- (GFunc) g_free,
- NULL);
- g_slist_free (crawl_directories);
- crawl_directories = NULL;
- }
- g_slice_free (ForEachDBCon, info);
-
- tracker_db_interface_end_transaction (db_con->cache->db);
-
- /* Signal progress */
- g_signal_emit_by_name (object, "index-progress",
- "Files",
- "",
- tracker->index_count,
- tracker->folders_processed,
- tracker->folders_count);
-
- g_slist_free (index_include);
-}
-
-static void
-process_index_crawl_add_directories (Tracker *tracker,
- GSList *dirs)
+process_index_crawl_add_directories (GSList *dirs)
{
GSList *new_dirs = NULL;
GSList *l;
- if (!tracker->is_running) {
- return;
- }
-
for (l = dirs; l; l = l->next) {
if (!l->data) {
continue;
@@ -937,13 +573,13 @@
continue;
}
- if (tracker_process_files_should_be_watched (tracker->config, l->data)) {
+ if (tracker_process_files_should_be_watched (config, l->data)) {
crawl_directories = g_slist_prepend (crawl_directories, g_strdup (l->data));
}
}
for (l = new_dirs; l; l = l->next) {
- process_get_directories (tracker, l->data, &files);
+ process_get_directories (l->data, &files);
}
g_slist_foreach (new_dirs, (GFunc) g_free, NULL);
@@ -954,16 +590,15 @@
}
static void
-process_index_crawl_files (Tracker *tracker, DBConnection *db_con)
+process_index_crawl_files (DBConnection *db_con)
{
- GSList *crawl_directory_roots;
- ForEachDBCon *info;
+ GSList *crawl_directory_roots;
g_message ("Starting directory crawling...");
crawl_directories = NULL;
crawl_directory_roots =
- tracker_config_get_crawl_directory_roots (tracker->config);
+ tracker_config_get_crawl_directory_roots (config);
if (!crawl_directory_roots) {
return;
@@ -971,14 +606,11 @@
tracker_db_interface_start_transaction (db_con->cache->db);
- process_index_crawl_add_directories (tracker, crawl_directory_roots);
- info = g_slice_new (ForEachDBCon);
- info->tracker = tracker;
- info->db_con = db_con;
+ process_index_crawl_add_directories (crawl_directory_roots);
g_slist_foreach (crawl_directories,
(GFunc) process_schedule_directory_check_foreach,
- info);
+ db_con);
if (crawl_directories) {
g_slist_foreach (crawl_directories, (GFunc) g_free, NULL);
@@ -988,9 +620,7 @@
g_slist_foreach (crawl_directory_roots,
(GFunc) process_schedule_directory_check_foreach,
- info);
-
- g_slice_free (ForEachDBCon, info);
+ db_con);
if (crawl_directories) {
g_slist_foreach (crawl_directories, (GFunc) g_free, NULL);
@@ -1001,295 +631,11 @@
tracker_db_interface_end_transaction (db_con->cache->db);
}
-static void
-process_index_conversations (Tracker *tracker, DBConnection *db_con)
-{
- gchar *gaim, *purple;
- gboolean has_logs = FALSE;
- GSList *list = NULL;
-
- gaim = g_build_filename (g_get_home_dir(), ".gaim", "logs", NULL);
- purple = g_build_filename (g_get_home_dir(), ".purple", "logs", NULL);
-
- if (tracker_file_is_valid (gaim)) {
- has_logs = TRUE;
- tracker_ontology_add_dir_to_service_type ("GaimConversations", gaim);
- list = g_slist_prepend (NULL, gaim);
- }
-
- if (tracker_file_is_valid (purple)) {
- has_logs = TRUE;
- tracker_ontology_add_dir_to_service_type ("GaimConversations", purple);
- list = g_slist_prepend (NULL, purple);
- }
-
- if (has_logs) {
- g_message ("Starting chat log indexing...");
- tracker_db_interface_start_transaction (db_con->cache->db);
- process_directory_list (tracker, list, TRUE, db_con);
- tracker_db_interface_end_transaction (db_con->cache->db);
- g_slist_free (list);
- }
-
- g_free (gaim);
- g_free (purple);
-}
-
-static void
-process_index_webhistory (Tracker *tracker, DBConnection *db_con)
-{
- GSList *list = NULL;
- gchar *firefox_dir;
-
- firefox_dir = g_build_filename (g_get_home_dir(), ".xesam/Firefox/ToIndex", NULL);
-
- if (tracker_file_is_valid (firefox_dir)) {
- list = g_slist_prepend( NULL, firefox_dir);
-
- g_message ("Starting Firefox web history indexing...");
- tracker_ontology_add_dir_to_service_type ("WebHistory", firefox_dir);
-
- tracker_db_interface_start_transaction (db_con->cache->db);
- process_directory_list (tracker, list, TRUE, db_con);
- tracker_db_interface_end_transaction (db_con->cache->db);
- g_slist_free (list);
- }
-
- g_free (firefox_dir);
-}
-
-static void
-process_index_emails (Tracker *tracker, DBConnection *db_con)
-{
- TrackerConfig *config;
- GObject *daemon;
-
- config = tracker->config;
-
- tracker_db_end_index_transaction (db_con);
- tracker_cache_flush_all ();
-
- tracker_indexer_merge_indexes (INDEX_TYPE_FILES);
-
- if (tracker->shutdown) {
- return;
- }
-
- tracker_index_stage_set (TRACKER_INDEX_STAGE_EMAILS);
-
- /* Signal progress */
- daemon = tracker_dbus_get_object (TRACKER_TYPE_DAEMON);
- g_signal_emit_by_name (daemon, "index-progress",
- "Emails",
- "",
- tracker->index_count,
- tracker->mbox_processed,
- tracker->mbox_count);
-
- if (tracker->word_update_count > 0) {
- tracker_indexer_apply_changes (tracker->file_index, tracker->file_update_index, TRUE);
- }
-
- tracker_db_start_index_transaction (db_con);
-
- if (tracker_config_get_email_client (tracker->config)) {
- const gchar *name;
-
- tracker_email_add_service_directories (db_con->emails);
- g_message ("Starting email indexing...");
-
- tracker_db_interface_start_transaction (db_con->cache->db);
-
- name = tracker_email_get_name ();
-
- if (name) {
- GSList *list;
-
- list = tracker_ontology_get_dirs_for_service_type (name);
- process_directory_list (tracker, list, TRUE, db_con);
- g_slist_free (list);
- }
-
- tracker_db_interface_end_transaction (db_con->cache->db);
- }
-}
-
-static gboolean
-process_files (Tracker *tracker, DBConnection *db_con)
-{
- GObject *object;
- TrackerIndexStage stage;
-
- object = tracker_dbus_get_object (TRACKER_TYPE_DAEMON);
-
- /* Check dir_queue in case there are
- * directories waiting to be indexed.
- */
- if (g_async_queue_length (dir_queue) > 0) {
- gchar *uri;
-
- uri = g_async_queue_try_pop (dir_queue);
-
- if (uri) {
- process_check_directory (tracker, uri);
- g_free (uri);
- return TRUE;
- }
- }
-
- stage = tracker_index_stage_get ();
-
- if (stage != TRACKER_INDEX_STAGE_FINISHED) {
- g_mutex_unlock (tracker->files_check_mutex);
-
- switch (stage) {
- case TRACKER_INDEX_STAGE_CONFIG:
- process_index_config (tracker, db_con);
- break;
-
- case TRACKER_INDEX_STAGE_APPLICATIONS:
- process_index_applications (tracker, db_con);
- break;
-
- case TRACKER_INDEX_STAGE_FILES:
- process_index_files (tracker, db_con);
- break;
-
- case TRACKER_INDEX_STAGE_CRAWL_FILES:
- process_index_crawl_files (tracker, db_con);
- break;
-
- case TRACKER_INDEX_STAGE_CONVERSATIONS:
- process_index_conversations (tracker, db_con);
- break;
-
- case TRACKER_INDEX_STAGE_WEBHISTORY:
- process_index_webhistory (tracker, db_con);
- break;
-
- case TRACKER_INDEX_STAGE_EXTERNAL:
- break;
-
- case TRACKER_INDEX_STAGE_EMAILS:
- process_index_emails (tracker, db_con);
- break;
-
- case TRACKER_INDEX_STAGE_FINISHED:
- break;
- }
-
- tracker_index_stage_set (++stage);
- return TRUE;
- }
-
- tracker_db_end_index_transaction (db_con);
- tracker_cache_flush_all ();
- /* I am unsure about this one (Philip Van Hoof)
- tracker_db_refresh_all (db_con); */
- tracker_indexer_merge_indexes (INDEX_TYPE_FILES);
-
- if (tracker->shutdown) {
- return FALSE;
- }
-
- if (tracker->word_update_count > 0) {
- tracker_indexer_apply_changes (tracker->file_index,
- tracker->file_update_index,
- TRUE);
- }
-
- tracker_indexer_merge_indexes (INDEX_TYPE_EMAILS);
-
- if (tracker->shutdown) {
- return FALSE;
- }
-
- tracker_index_stage_set (TRACKER_INDEX_STAGE_FILES);
-
- /* Signal progress */
- g_signal_emit_by_name (object,
- "index-progress",
- "Files",
- "",
- tracker->index_count,
- tracker->folders_processed,
- tracker->folders_count);
-
- tracker_index_stage_set (TRACKER_INDEX_STAGE_FINISHED);
-
- if (tracker->is_running && tracker->first_time_index) {
- gint time_taken;
-
- tracker_status_set (TRACKER_STATUS_OPTIMIZING);
-
- tracker->first_time_index = FALSE;
-
- time_taken = (gint) g_timer_elapsed (index_duration, NULL);
- g_timer_destroy (index_duration);
- index_duration = NULL;
-
- g_message ("Indexing finished in %d seconds", time_taken);
- g_signal_emit_by_name (object, "index-finished", time_taken);
-
- tracker_db_set_option_int (db_con, "InitialIndex", 0);
-
- g_message ("Updating database stats, please wait...");
-
- tracker_db_interface_start_transaction (db_con->db);
- tracker_db_exec_no_reply (db_con->db, "ANALYZE");
- tracker_db_interface_end_transaction (db_con->db);
-
- tracker_db_interface_start_transaction (db_con->emails->db);
- tracker_db_exec_no_reply (db_con->emails->db, "ANALYZE");
- tracker_db_interface_end_transaction (db_con->emails->db);
-
- g_message ("Finished optimizing, waiting for new events...");
- }
-
- /* We have no stuff to process so sleep until awoken by a new
- * signal.
- */
- tracker_status_set_and_signal (TRACKER_STATUS_IDLE,
- tracker->first_time_index,
- tracker->in_merge,
- tracker->pause_manual,
- tracker_should_pause_on_battery (),
- tracker->pause_io,
- tracker_config_get_enable_indexing (tracker->config));
-
- /* Signal state change */
- g_signal_emit_by_name (object,
- "index-state-change",
- tracker_status_get_as_string (),
- tracker->first_time_index,
- tracker->in_merge,
- tracker->pause_manual,
- tracker_should_pause_on_battery (),
- tracker->pause_io,
- tracker_config_get_enable_indexing (tracker->config));
-
- g_cond_wait (tracker->files_signal_cond,
- tracker->files_signal_mutex);
-
- tracker->grace_period = 0;
-
- /* Determine if wake up call is new
- * stuff or a shutdown signal.
- */
- if (!tracker->shutdown) {
- tracker_db_start_index_transaction (db_con);
- return TRUE;
- }
-
- return FALSE;
-}
-
static gboolean
-process_action (Tracker *tracker,
- TrackerDBFileInfo *info,
+process_action (TrackerDBFileInfo *info,
DBConnection *db_con)
{
- gboolean need_index;
+ gboolean need_index;
need_index = info->mtime > info->indextime;
@@ -1305,18 +651,16 @@
case TRACKER_DB_ACTION_FILE_MOVED_FROM:
need_index = FALSE;
- g_message ("Starting moving file:'%s' to:'%s'", info->uri, info->moved_to_uri);
+ g_message ("Starting moving file:'%s' to:'%s'",
+ info->uri,
+ info->moved_to_uri);
tracker_db_move_file (db_con, info->uri, info->moved_to_uri);
break;
case TRACKER_DB_ACTION_DIRECTORY_REFRESH:
if (need_index &&
- tracker_process_files_should_be_watched (tracker->config, info->uri)) {
+ tracker_process_files_should_be_watched (config, info->uri)) {
g_async_queue_push (dir_queue, g_strdup (info->uri));
-
- if (tracker_index_stage_get () != TRACKER_INDEX_STAGE_EMAILS) {
- tracker->folders_count++;
- }
}
need_index = FALSE;
@@ -1324,11 +668,11 @@
case TRACKER_DB_ACTION_DIRECTORY_CHECK:
if (need_index &&
- tracker_process_files_should_be_watched (tracker->config, info->uri)) {
+ tracker_process_files_should_be_watched (config, info->uri)) {
g_async_queue_push (dir_queue, g_strdup (info->uri));
if (info->indextime > 0) {
- process_index_delete_directory_check (tracker, info->uri, db_con);
+ process_index_delete_directory_check (info->uri, db_con);
}
}
@@ -1346,7 +690,7 @@
/* Schedule a rescan for all files in folder
* to avoid race conditions.
*/
- if (tracker_process_files_should_be_watched (tracker->config, info->uri)) {
+ if (tracker_process_files_should_be_watched (config, info->uri)) {
GSList *list;
/* Add to watch folders (including
@@ -1354,8 +698,8 @@
*/
list = g_slist_prepend (NULL, info->uri);
- process_watch_directories (tracker, list, db_con);
- process_scan_directory (tracker, info->uri, db_con);
+ process_watch_directories (list, db_con);
+ process_scan_directory (info->uri, db_con);
g_slist_free (list);
} else {
@@ -1372,112 +716,11 @@
return need_index;
}
-static gboolean
-process_action_prechecks (Tracker *tracker,
- TrackerDBFileInfo *info,
- DBConnection *db_con)
-{
-
- /* Info struct may have been deleted in transit here
- * so check if still valid and intact.
- */
- if (!tracker_process_files_is_file_info_valid (info)) {
- return TRUE;
- }
-
-
- if (info->file_id == 0 &&
- info->action != TRACKER_DB_ACTION_CREATE &&
- info->action != TRACKER_DB_ACTION_DIRECTORY_CREATED &&
- info->action != TRACKER_DB_ACTION_FILE_CREATED) {
- info = tracker_db_get_file_info (db_con, info);
-
- /* Get more file info if db retrieval returned nothing */
- if (info->file_id == 0) {
- info = tracker_db_file_info_get (info);
- info->is_new = TRUE;
- } else {
- info->is_new = FALSE;
- }
- } else {
- info->is_new = TRUE;
- }
-
- g_message ("Processing:'%s' with action:'%s' and counter:%d ",
- info->uri,
- tracker_db_action_to_string (info->action),
- info->counter);
-
- /* Preprocess ambiguous actions when we need to work
- * out if its a file or a directory that the action
- * relates to.
- */
- process_action_verify (info);
-
- if (info->action != TRACKER_DB_ACTION_DELETE &&
- info->action != TRACKER_DB_ACTION_DIRECTORY_DELETED &&
- info->action != TRACKER_DB_ACTION_DIRECTORY_UNMOUNTED &&
- info->action != TRACKER_DB_ACTION_FILE_DELETED) {
- if (!tracker_file_is_valid (info->uri) ) {
- gboolean invalid = TRUE;
-
- if (info->moved_to_uri) {
- invalid = !tracker_file_is_valid (info->moved_to_uri);
- }
-
- if (invalid) {
- tracker_db_file_info_free (info);
- return TRUE;
- }
- }
-
- /* Get file ID and other interesting fields
- * from Database if not previously fetched or
- * is newly created.
- */
- } else {
- if (info->action == TRACKER_DB_ACTION_FILE_DELETED) {
- process_index_delete_file (tracker, info, db_con);
- info = tracker_db_file_info_unref (info);
- return TRUE;
- } else {
- if (info->action == TRACKER_DB_ACTION_DIRECTORY_DELETED ||
- info->action == TRACKER_DB_ACTION_DIRECTORY_UNMOUNTED) {
- process_index_delete_file (tracker, info, db_con);
- process_index_delete_directory (tracker, info, db_con);
- info = tracker_db_file_info_unref (info);
- return TRUE;
- }
- }
- }
-
- /* Get latest file info from disk */
- if (info->mtime == 0) {
- info = tracker_db_file_info_get (info);
- }
-
- return FALSE;
-}
-
-static void
-process_block_signals (void)
-{
- sigset_t signal_set;
-
- /* Block all signals in this thread */
- sigfillset (&signal_set);
-
-#ifndef OS_WIN32
- pthread_sigmask (SIG_BLOCK, &signal_set, NULL);
-#endif
-}
-
#ifdef HAVE_HAL
static void
-process_mount_point_added_cb (TrackerHal *hal,
- const gchar *mount_point,
- Tracker *tracker,
+process_mount_point_added_cb (TrackerHal *hal,
+ const gchar *mount_point,
DBConnection *db_con)
{
GSList *list;
@@ -1485,19 +728,18 @@
g_message ("** TRAWLING THROUGH NEW MOUNT POINT:'%s'", mount_point);
list = g_slist_prepend (NULL, (gchar*) mount_point);
- process_directory_list (tracker, list, TRUE, db_con);
+ process_directory_list (list, TRUE, db_con);
g_slist_free (list);
}
static void
process_mount_point_removed_cb (TrackerHal *hal,
const gchar *mount_point,
- Tracker *tracker,
DBConnection *db_con)
{
g_message ("** CLEANING UP OLD MOUNT POINT:'%s'", mount_point);
- process_index_delete_directory_check (tracker, mount_point, db_con);
+ process_index_delete_directory_check (mount_point, db_con);
}
#endif /* HAVE_HAL */
@@ -1519,43 +761,27 @@
/* This is the thread entry point for the indexer to start processing
* files and all other categories for processing.
*/
-gpointer
-tracker_process_files (gpointer data)
+gboolean
+tracker_process_files_init (Tracker *tracker)
{
- Tracker *tracker;
- DBConnection *db_con;
- GObject *object;
- GSList *moved_from_list; /* List to hold moved_from
- * events whilst waiting for a
- * matching moved_to event.
- */
- gboolean pushed_events;
- gboolean first_run;
- gint initial_sleep;
-
- /* Set up thread */
- process_block_signals ();
+ GObject *object;
- tracker = (Tracker*) data;
+ g_return_val_if_fail (tracker != NULL, FALSE);
- /* Lock this process */
- g_mutex_lock (tracker->files_signal_mutex);
+ hal = g_object_ref (tracker->hal);
+ config = g_object_ref (tracker->config);
- /* Get pointers we need */
db_con = tracker_db_connect_all ();
- object = tracker_dbus_get_object (TRACKER_TYPE_DAEMON);
dir_queue = g_async_queue_new ();
file_metadata_queue = g_async_queue_new ();
file_process_queue = g_async_queue_new ();
- tracker->pause_io = TRUE;
-
/* When initially run, we set up variables */
if (!ignore_pattern_list) {
GSList *no_index_file_types;
- no_index_file_types = tracker_config_get_no_index_file_types (tracker->config);
+ no_index_file_types = tracker_config_get_no_index_file_types (config);
if (no_index_file_types) {
GPatternSpec *spec;
@@ -1573,16 +799,15 @@
}
#ifdef HAVE_HAL
- g_signal_connect (tracker->hal, "mount-point-added",
+ g_signal_connect (hal, "mount-point-added",
G_CALLBACK (process_mount_point_added_cb),
tracker);
- g_signal_connect (tracker->hal, "mount-point-removed",
+ g_signal_connect (hal, "mount-point-removed",
G_CALLBACK (process_mount_point_removed_cb),
tracker);
#endif /* HAVE_HAL */
- /* Start processing */
- g_mutex_unlock (tracker->files_signal_mutex);
+ object = tracker_dbus_get_object (TRACKER_TYPE_DAEMON);
/* Signal state change */
g_signal_emit_by_name (object,
@@ -1593,213 +818,93 @@
tracker->pause_manual,
tracker_should_pause_on_battery (),
tracker->pause_io,
- tracker_config_get_enable_indexing (tracker->config));
-
- /* Sleep for N secs before watching/indexing any of the major services */
- initial_sleep = tracker_config_get_initial_sleep (tracker->config);
- g_message ("Sleeping for:%d secs before starting...", initial_sleep);
-
- while (initial_sleep > 0) {
- g_usleep (G_USEC_PER_SEC);
-
- initial_sleep --;
-
- if (!tracker->is_running || tracker->shutdown) {
- g_mutex_unlock (tracker->files_signal_mutex);
- return NULL;
- }
- }
+ tracker_config_get_enable_indexing (config));
- g_message ("Proceeding with indexing...");
+ g_message ("Processing files...");
- tracker_index_stage_set (TRACKER_INDEX_STAGE_CONFIG);
-
- object = tracker_dbus_get_object (TRACKER_TYPE_DAEMON);
-
- pushed_events = FALSE;
- first_run = TRUE;
- moved_from_list = NULL;
-
- g_message ("Starting indexing...");
-
- if (index_duration) {
- g_timer_destroy (index_duration);
- }
-
- index_duration = g_timer_new ();
-
- while (TRUE) {
+ /* FIXME: Needs working on */
+ while (FALSE) {
TrackerDBFileInfo *info;
gboolean need_index;
- if (!tracker_cache_process_events (db_con, TRUE) ) {
- tracker_status_set_and_signal (TRACKER_STATUS_SHUTDOWN,
- tracker->first_time_index,
- tracker->in_merge,
- tracker->pause_manual,
- tracker_should_pause_on_battery (),
- tracker->pause_io,
- tracker_config_get_enable_indexing (tracker->config));
- break;
- }
-
tracker_status_set_and_signal (TRACKER_STATUS_INDEXING,
tracker->first_time_index,
tracker->in_merge,
tracker->pause_manual,
tracker_should_pause_on_battery (),
tracker->pause_io,
- tracker_config_get_enable_indexing (tracker->config));
+ tracker_config_get_enable_indexing (config));
info = g_async_queue_try_pop (file_process_queue);
-
- /* Check pending table if we haven't got anything */
- if (!info) {
- TrackerDBResultSet *result_set;
- gint k;
-
- if (!tracker_db_has_pending_files (db_con)) {
- gboolean should_continue;
-
- /* Set mutex to indicate we are in "check" state */
- g_mutex_lock (tracker->files_check_mutex);
- should_continue = process_files (tracker, db_con);
- g_mutex_unlock (tracker->files_check_mutex);
-
- if (should_continue) {
- continue;
- }
-
- if (tracker->shutdown) {
- break;
- }
- }
-
- result_set = tracker_db_get_pending_files (db_con);
-
- k = 0;
- pushed_events = FALSE;
-
- if (result_set) {
- gboolean valid = TRUE;
-
- tracker_status_set (TRACKER_STATUS_PENDING);
-
- while (valid) {
- TrackerDBFileInfo *info_tmp;
- TrackerDBAction tmp_action;
- gchar *uri;
-
- if (!tracker->is_running) {
- g_object_unref (result_set);
- break;
- }
-
- tracker_db_result_set_get (result_set,
- 1, &uri,
- 2, &tmp_action,
- -1);
-
- info_tmp = tracker_db_file_info_new (uri, tmp_action, 0, TRACKER_DB_WATCH_OTHER);
- g_async_queue_push (file_process_queue, info_tmp);
- pushed_events = TRUE;
-
- valid = tracker_db_result_set_iter_next (result_set);
- g_free (uri);
- }
-
- g_object_unref (result_set);
- }
-
- if (!tracker->is_running) {
- continue;
- }
-
- tracker_db_remove_pending_files (db_con);
-
- /* Pending files are present but not yet ready
- * as we are waiting til they stabilize so we
- * should sleep for 100ms (only occurs when
- * using FAM or inotify move/create).
- */
- if (!pushed_events && k == 0) {
- g_usleep (100000);
- }
-
- continue;
- }
-
- tracker_status_set_and_signal (TRACKER_STATUS_INDEXING,
- tracker->first_time_index,
- tracker->in_merge,
- tracker->pause_manual,
- tracker_should_pause_on_battery (),
- tracker->pause_io,
- tracker_config_get_enable_indexing (tracker->config));
-
- if (process_action_prechecks (tracker, info, db_con)) {
+
+ if (!info) {
+ process_my_yield ();
continue;
}
-
+
/* Check if file needs indexing */
- need_index = process_action (tracker, info, db_con);
+ need_index = process_action (info, db_con);
- if (need_index) {
- if (tracker_db_regulate_transactions (db_con, 250)) {
- if (tracker_config_get_verbosity (tracker->config) == 1) {
- g_message ("Indexing #%d, '%s'",
- tracker->index_count,
- info->uri);
- }
-
- /* Signal progress */
- object = tracker_dbus_get_object (TRACKER_TYPE_DAEMON);
- g_signal_emit_by_name (object,
- "index-progress",
- "Files",
- info->uri,
- tracker->index_count,
- tracker->folders_processed,
- tracker->folders_count);
- }
+ /* FIXME: Finish, maybe call the indexer with the new file */
+ if (0) {
+ GSList *foo, *bar;
+ process_check_directory(NULL);
+ process_index_get_roots(&foo, &bar);
+ process_index_crawl_files(db_con);
+ }
- process_index_entity (tracker, info, db_con);
- }
tracker_db_file_info_unref (info);
}
-#ifdef HAVE_HAL
- g_signal_handlers_disconnect_by_func (tracker->hal,
- process_mount_point_added_cb,
- tracker);
- g_signal_handlers_disconnect_by_func (tracker->hal,
- process_mount_point_removed_cb,
- tracker);
-#endif /* HAVE_HAL */
+ return TRUE;
+}
+void
+tracker_process_files_shutdown (void)
+{
+ /* FIXME: do we need this? */
xdg_mime_shutdown ();
- tracker_db_close_all (db_con);
-
/* Clean up */
if (file_process_queue) {
g_async_queue_unref (file_process_queue);
+ file_process_queue = NULL;
}
if (file_metadata_queue) {
g_async_queue_unref (file_metadata_queue);
+ file_metadata_queue = NULL;
}
if (dir_queue) {
g_async_queue_unref (dir_queue);
+ dir_queue = NULL;
}
- g_mutex_unlock (tracker->files_signal_mutex);
+ tracker_db_close_all (db_con);
+ db_con = NULL;
+
+ if (config) {
+ g_object_unref (config);
+ config = NULL;
+ }
+
+#ifdef HAVE_HAL
+ g_signal_handlers_disconnect_by_func (hal,
+ process_mount_point_added_cb,
+ NULL);
+ g_signal_handlers_disconnect_by_func (hal,
+ process_mount_point_removed_cb,
+ NULL);
+#endif /* HAVE_HAL */
- g_message ("Process thread now finishing");
+ if (hal) {
+ g_object_unref (hal);
+ hal = NULL;
+ }
- return NULL;
+ g_message ("Process files now finishing");
}
gboolean
@@ -1855,8 +960,7 @@
}
gboolean
-tracker_process_files_should_be_crawled (Tracker *tracker,
- const gchar *uri)
+tracker_process_files_should_be_crawled (const gchar *uri)
{
GSList *crawl_directory_roots;
GSList *mounted_directory_roots = NULL;
@@ -1866,20 +970,18 @@
gboolean index_removable_devices;
gboolean should_be_crawled = TRUE;
- g_return_val_if_fail (tracker != NULL, FALSE);
g_return_val_if_fail (uri != NULL, FALSE);
g_return_val_if_fail (uri[0] == G_DIR_SEPARATOR, FALSE);
- index_mounted_directories = tracker_config_get_index_mounted_directories (tracker->config);
- index_removable_devices = tracker_config_get_index_removable_devices (tracker->config);
+ index_mounted_directories = tracker_config_get_index_mounted_directories (config);
+ index_removable_devices = tracker_config_get_index_removable_devices (config);
if (!index_mounted_directories || !index_removable_devices) {
- process_index_get_remote_roots (tracker,
- &mounted_directory_roots,
+ process_index_get_remote_roots (&mounted_directory_roots,
&removable_device_roots);
}
- l = tracker_config_get_crawl_directory_roots (tracker->config);
+ l = tracker_config_get_crawl_directory_roots (config);
crawl_directory_roots = g_slist_copy (l);
@@ -2026,13 +1128,12 @@
}
void
-tracker_process_files_get_all_dirs (Tracker *tracker,
- const char *dir,
+tracker_process_files_get_all_dirs (const char *dir,
GSList **files)
{
GSList *l;
- l = process_get_files (tracker, dir, TRUE, FALSE, NULL);
+ l = process_get_files (dir, TRUE, FALSE, NULL);
if (*files) {
*files = g_slist_concat (*files, l);
@@ -2042,11 +1143,10 @@
}
GSList *
-tracker_process_files_get_files_with_prefix (Tracker *tracker,
- const char *dir,
+tracker_process_files_get_files_with_prefix (const char *dir,
const char *prefix)
{
- return process_get_files (tracker, dir, FALSE, FALSE, prefix);
+ return process_get_files (dir, FALSE, FALSE, prefix);
}
gboolean
Modified: branches/xesam-support/src/trackerd/tracker-process-files.h
==============================================================================
--- branches/xesam-support/src/trackerd/tracker-process-files.h (original)
+++ branches/xesam-support/src/trackerd/tracker-process-files.h Mon Jun 2 18:57:26 2008
@@ -31,12 +31,12 @@
G_BEGIN_DECLS
-/* Thread entry point */
-gpointer tracker_process_files (gpointer data);
+gboolean tracker_process_files_init (Tracker *tracker);
+void tracker_process_files_shutdown (void);
+
gboolean tracker_process_files_should_be_watched (TrackerConfig *config,
const gchar *uri);
-gboolean tracker_process_files_should_be_crawled (Tracker *tracker,
- const gchar *uri);
+gboolean tracker_process_files_should_be_crawled (const gchar *uri);
gboolean tracker_process_files_should_be_ignored (const char *uri);
/* Black list API */
@@ -45,11 +45,9 @@
void tracker_process_files_append_temp_black_list (const gchar *str);
/* File/Directory API */
-void tracker_process_files_get_all_dirs (Tracker *tracker,
- const char *dir,
+void tracker_process_files_get_all_dirs (const char *dir,
GSList **files);
-GSList * tracker_process_files_get_files_with_prefix (Tracker *tracker,
- const char *dir,
+GSList * tracker_process_files_get_files_with_prefix (const char *dir,
const char *prefix);
gboolean tracker_process_files_is_file_info_valid (TrackerDBFileInfo *info);
Modified: branches/xesam-support/src/trackerd/tracker-utils.c
==============================================================================
--- branches/xesam-support/src/trackerd/tracker-utils.c (original)
+++ branches/xesam-support/src/trackerd/tracker-utils.c Mon Jun 2 18:57:26 2008
@@ -128,19 +128,6 @@
g_hash_table_insert (meta_table, (gchar*) key, list);
}
-void
-tracker_add_io_grace (const gchar *uri)
-{
- if (tracker_xesam_manager_is_uri_in_xesam_dir (uri)) {
- return;
- }
-
- g_message ("File changes to:'%s' is causing tracker to pause...",
- uri);
-
- tracker->grace_period++;
-}
-
gboolean
tracker_is_low_diskspace (void)
{
Modified: branches/xesam-support/src/trackerd/tracker-xesam-manager.c
==============================================================================
--- branches/xesam-support/src/trackerd/tracker-xesam-manager.c (original)
+++ branches/xesam-support/src/trackerd/tracker-xesam-manager.c Mon Jun 2 18:57:26 2008
@@ -34,8 +34,6 @@
static gchar *xesam_dir;
static gboolean live_search_handler_running = FALSE;
-static void tracker_xesam_manager_wakeup (gpointer user_data);
-
GQuark
tracker_xesam_manager_error_quark (void)
{
@@ -342,7 +340,7 @@
live_search_handler_running = FALSE;
}
-static void
+void
tracker_xesam_manager_wakeup (gpointer user_data)
{
/* This happens each time a new event is created */
Modified: branches/xesam-support/src/trackerd/tracker-xesam-manager.h
==============================================================================
--- branches/xesam-support/src/trackerd/tracker-xesam-manager.h (original)
+++ branches/xesam-support/src/trackerd/tracker-xesam-manager.h Mon Jun 2 18:57:26 2008
@@ -64,6 +64,7 @@
gchar * tracker_xesam_manager_generate_unique_key (void);
gboolean tracker_xesam_manager_is_uri_in_xesam_dir (const gchar *uri);
void tracker_xesam_subscribe_indexer_updated (DBusGProxy *proxy);
+void tracker_xesam_manager_wakeup (gpointer user_data);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]