tracker r1561 - in branches/indexer-split: . src/trackerd
- From: mr svn gnome org
- To: svn-commits-list gnome org
- Subject: tracker r1561 - in branches/indexer-split: . src/trackerd
- Date: Mon, 2 Jun 2008 16:55:24 +0000 (UTC)
Author: mr
Date: Mon Jun 2 16:55:23 2008
New Revision: 1561
URL: http://svn.gnome.org/viewvc/tracker?rev=1561&view=rev
Log:
* src/trackerd/Makefile.am:
* src/trackerd/tracker-cache.[ch]:
* src/trackerd/tracker-db-email.c:
* src/trackerd/tracker-db-sqlite.c:
* src/trackerd/tracker-db.c:
* src/trackerd/tracker-email-evolution.c:
* src/trackerd/tracker-email-modest.c:
* src/trackerd/tracker-email-utils.c: Removed tracker-cache.[ch]
now used in the tracker-indexer code and cleaned up all places
that call cache functions.
* src/trackerd/tracker-email-kmail.c:
* src/trackerd/tracker-indexer.c:
* src/trackerd/tracker-watch.h:
* src/trackerd/tracker-inotify.c: Refactored the code here and
changed the API to be more consistent.
* src/trackerd/tracker-utils.c: Removed the _add_io_grace()
function now it is no longer used.
Removed:
branches/indexer-split/src/trackerd/tracker-cache.c
branches/indexer-split/src/trackerd/tracker-cache.h
Modified:
branches/indexer-split/ChangeLog
branches/indexer-split/src/trackerd/Makefile.am
branches/indexer-split/src/trackerd/tracker-db-email.c
branches/indexer-split/src/trackerd/tracker-db-sqlite.c
branches/indexer-split/src/trackerd/tracker-db.c
branches/indexer-split/src/trackerd/tracker-email-evolution.c
branches/indexer-split/src/trackerd/tracker-email-kmail.c
branches/indexer-split/src/trackerd/tracker-email-modest.c
branches/indexer-split/src/trackerd/tracker-email-utils.c
branches/indexer-split/src/trackerd/tracker-indexer.c
branches/indexer-split/src/trackerd/tracker-inotify.c
branches/indexer-split/src/trackerd/tracker-main.c
branches/indexer-split/src/trackerd/tracker-main.h
branches/indexer-split/src/trackerd/tracker-process-files.c
branches/indexer-split/src/trackerd/tracker-process-files.h
branches/indexer-split/src/trackerd/tracker-utils.c
branches/indexer-split/src/trackerd/tracker-watch.h
Modified: branches/indexer-split/src/trackerd/Makefile.am
==============================================================================
--- branches/indexer-split/src/trackerd/Makefile.am (original)
+++ branches/indexer-split/src/trackerd/Makefile.am Mon Jun 2 16:55:23 2008
@@ -65,8 +65,6 @@
$(watch_sources) \
$(win_sources) \
$(unix_sources) \
- tracker-cache.c \
- tracker-cache.h \
tracker-daemon.c \
tracker-daemon.h \
tracker-db.c \
@@ -89,13 +87,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/indexer-split/src/trackerd/tracker-db-email.c
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-db-email.c (original)
+++ branches/indexer-split/src/trackerd/tracker-db-email.c Mon Jun 2 16:55:23 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/indexer-split/src/trackerd/tracker-db-sqlite.c
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-db-sqlite.c (original)
+++ branches/indexer-split/src/trackerd/tracker-db-sqlite.c Mon Jun 2 16:55:23 2008
@@ -41,7 +41,6 @@
#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"
@@ -2298,7 +2297,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);
@@ -4275,19 +4276,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 +4362,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/indexer-split/src/trackerd/tracker-db.c
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-db.c (original)
+++ branches/indexer-split/src/trackerd/tracker-db.c Mon Jun 2 16:55:23 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/indexer-split/src/trackerd/tracker-email-evolution.c
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-email-evolution.c (original)
+++ branches/indexer-split/src/trackerd/tracker-email-evolution.c Mon Jun 2 16:55:23 2008
@@ -41,7 +41,6 @@
#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"
@@ -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/indexer-split/src/trackerd/tracker-email-kmail.c
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-email-kmail.c (original)
+++ branches/indexer-split/src/trackerd/tracker-email-kmail.c Mon Jun 2 16:55:23 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-watch.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/indexer-split/src/trackerd/tracker-email-modest.c
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-email-modest.c (original)
+++ branches/indexer-split/src/trackerd/tracker-email-modest.c Mon Jun 2 16:55:23 2008
@@ -41,7 +41,6 @@
#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"
@@ -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/indexer-split/src/trackerd/tracker-email-utils.c
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-email-utils.c (original)
+++ branches/indexer-split/src/trackerd/tracker-email-utils.c Mon Jun 2 16:55:23 2008
@@ -35,7 +35,6 @@
#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"
@@ -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/indexer-split/src/trackerd/tracker-indexer.c
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-indexer.c (original)
+++ branches/indexer-split/src/trackerd/tracker-indexer.c Mon Jun 2 16:55:23 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/indexer-split/src/trackerd/tracker-inotify.c
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-inotify.c (original)
+++ branches/indexer-split/src/trackerd/tracker-inotify.c Mon Jun 2 16:55:23 2008
@@ -45,65 +45,99 @@
#define INOTIFY_WATCH_LIMIT "/proc/sys/fs/inotify/max_user_watches"
-/* project wide global vars */
+static void process_event (const gchar *uri,
+ gboolean is_dir,
+ TrackerDBAction action,
+ guint32 cookie);
extern Tracker *tracker;
extern DBConnection *main_thread_db_con;
-/* list to temporarily store moved_from events so they can be matched against moved_to events */
+static GIOChannel *channel;
static GSList *move_list;
-static GQueue *inotify_queue;
-static int inotify_monitor_fd = -1;
-static int inotify_count = 0;
+static GQueue *event_queue;
+static gint monitor_fd = -1;
+static gint monitor_count;
+static gint monitor_limit = 8191;
-static GIOChannel *gio;
-
-
-static gboolean process_moved_events ();
-
-
-gboolean
-tracker_is_directory_watched (const char * dir, DBConnection *db_con)
+static gboolean
+is_delete_event (TrackerDBAction event_type)
{
- TrackerDBResultSet *result_set;
- gint id;
+ return
+ event_type == TRACKER_DB_ACTION_DELETE ||
+ event_type == TRACKER_DB_ACTION_DELETE_SELF ||
+ event_type == TRACKER_DB_ACTION_FILE_DELETED ||
+ event_type == TRACKER_DB_ACTION_DIRECTORY_DELETED;
+}
- g_return_val_if_fail (dir != NULL && dir[0] == G_DIR_SEPARATOR, FALSE);
+static gboolean
+process_moved_events (void)
+{
+ GSList *l;
if (!tracker->is_running) {
return FALSE;
}
- result_set = tracker_exec_proc (db_con->cache, "GetWatchID", dir, NULL);
-
- if (!result_set) {
- return FALSE;
+ if (!move_list) {
+ return TRUE;
}
- tracker_db_result_set_get (result_set, 0, &id, -1);
- g_object_unref (result_set);
+ for (l = move_list; l; l = l->next) {
+ TrackerDBFileInfo *info;
- return (id >= 0);
-}
+ info = l->data;
+ /* Make it a DELETE if we have not received a
+ * corresponding MOVED_TO event after a certain
+ * period.
+ */
+ if (info->counter < 1 &&
+ (info->action == TRACKER_DB_ACTION_FILE_MOVED_FROM ||
+ info->action == TRACKER_DB_ACTION_DIRECTORY_MOVED_FROM)) {
+ /* Make sure file no longer exists before
+ * issuing a "delete".
+ */
+ if (!tracker_file_is_valid (info->uri)) {
+ if (info->action == TRACKER_DB_ACTION_DIRECTORY_MOVED_FROM) {
+ process_event (info->uri,
+ TRUE,
+ TRACKER_DB_ACTION_DIRECTORY_DELETED,
+ 0);
+ } else {
+ process_event (info->uri,
+ FALSE,
+ TRACKER_DB_ACTION_FILE_DELETED,
+ 0);
+ }
+ }
-static gboolean
-is_delete_event (TrackerDBAction event_type)
-{
- return (event_type == TRACKER_DB_ACTION_DELETE ||
- event_type == TRACKER_DB_ACTION_DELETE_SELF ||
- event_type == TRACKER_DB_ACTION_FILE_DELETED ||
- event_type == TRACKER_DB_ACTION_DIRECTORY_DELETED);
-}
+ move_list = g_slist_remove (move_list, info);
+ tracker_db_file_info_free (info);
+ continue;
+ } else {
+ info->counter--;
+ }
+ }
+
+ if (!move_list) {
+ return FALSE;
+ }
+ return TRUE;
+}
static void
-process_event (const char *uri, gboolean is_dir, TrackerDBAction action, guint32 cookie)
+process_event (const gchar *uri,
+ gboolean is_dir,
+ TrackerDBAction action,
+ guint32 cookie)
{
TrackerDBFileInfo *info;
- g_return_if_fail (uri && (uri[0] == '/'));
+ g_return_if_fail (uri != NULL);
+ g_return_if_fail (uri[0] == G_DIR_SEPARATOR);
info = tracker_db_file_info_new (uri, action, 1, TRACKER_DB_WATCH_OTHER);
@@ -114,7 +148,7 @@
info->is_directory = is_dir;
if (is_delete_event (action)) {
- char *parent;
+ gchar *parent;
parent = g_path_get_dirname (info->uri);
@@ -127,149 +161,148 @@
}
g_free (parent);
+
return;
}
- /* we are not interested in create events for non-folders (we use writable file closed instead) */
- if (action == TRACKER_DB_ACTION_DIRECTORY_CREATED) {
-
+ /* We are not interested in create events for non-folders (we
+ * use writable file closed instead).
+ */
+ switch (action) {
+ case TRACKER_DB_ACTION_DIRECTORY_CREATED:
info->action = TRACKER_DB_ACTION_DIRECTORY_CREATED;
info->is_directory = TRUE;
- tracker_db_insert_pending_file (main_thread_db_con, info->file_id, info->uri, NULL, info->mime, 0, info->action, info->is_directory, TRUE, -1);
+ tracker_db_insert_pending_file (main_thread_db_con,
+ info->file_id,
+ info->uri,
+ NULL,
+ info->mime,
+ 0,
+ info->action,
+ info->is_directory,
+ TRUE,
+ -1);
tracker_db_file_info_free (info);
- return;
-
- } else if (action == TRACKER_DB_ACTION_FILE_CREATED) {
- tracker_add_io_grace (info->uri);
+ break;
+ case TRACKER_DB_ACTION_FILE_CREATED:
tracker_db_file_info_free (info);
- return;
+ break;
- } else if (action == TRACKER_DB_ACTION_DIRECTORY_MOVED_FROM || action == TRACKER_DB_ACTION_FILE_MOVED_FROM) {
- tracker_add_io_grace (info->uri);
+ case TRACKER_DB_ACTION_DIRECTORY_MOVED_FROM:
+ case TRACKER_DB_ACTION_FILE_MOVED_FROM:
info->cookie = cookie;
info->counter = 1;
move_list = g_slist_prepend (move_list, info);
- g_timeout_add_full (G_PRIORITY_LOW,
- 350,
- (GSourceFunc) process_moved_events,
- NULL, NULL
- );
- return;
+
+ g_timeout_add_full (G_PRIORITY_LOW,
+ 350,
+ (GSourceFunc) process_moved_events,
+ NULL, NULL);
+ break;
- } else if (action == TRACKER_DB_ACTION_FILE_MOVED_TO || action == TRACKER_DB_ACTION_DIRECTORY_MOVED_TO) {
+ case TRACKER_DB_ACTION_FILE_MOVED_TO:
+ case TRACKER_DB_ACTION_DIRECTORY_MOVED_TO: {
TrackerDBFileInfo *moved_to_info;
- GSList *tmp;
+ GSList *l;
+ gboolean item_removed = FALSE;
moved_to_info = info;
- tracker_add_io_grace (info->uri);
- for (tmp = move_list; tmp; tmp = tmp->next) {
+
+ for (l = move_list; l && !item_removed; l = l->next) {
TrackerDBFileInfo *moved_from_info;
- moved_from_info = (TrackerDBFileInfo *) tmp->data;
+ moved_from_info = l->data;
if (!moved_from_info) {
- g_critical ("bad FileInfo struct found in move list. Skipping...");
continue;
}
- if ((cookie > 0) && (moved_from_info->cookie == cookie)) {
+ if (cookie > 0 && moved_from_info->cookie == cookie) {
+ TrackerDBAction action;
+ gboolean is_dir;
g_message ("Found matching inotify pair from:'%s' to:'%s'",
moved_from_info->uri,
moved_to_info->uri);
- tracker->grace_period = 2;
-
if (!tracker_file_is_directory (moved_to_info->uri)) {
- tracker_db_insert_pending_file (main_thread_db_con, moved_from_info->file_id, moved_from_info->uri, moved_to_info->uri, moved_from_info->mime, 0, TRACKER_DB_ACTION_FILE_MOVED_FROM, FALSE, TRUE, -1);
-
-// tracker_db_move_file (main_thread_db_con, moved_from_info->uri, moved_to_info->uri);
+ is_dir = FALSE;
+ action = TRACKER_DB_ACTION_FILE_MOVED_FROM;
} else {
- tracker_db_insert_pending_file (main_thread_db_con, moved_from_info->file_id, moved_from_info->uri, moved_to_info->uri, moved_from_info->mime, 0, TRACKER_DB_ACTION_DIRECTORY_MOVED_FROM, TRUE, TRUE, -1);
-// tracker_db_move_directory (main_thread_db_con, moved_from_info->uri, moved_to_info->uri);
+ is_dir = TRUE;
+ action = TRACKER_DB_ACTION_DIRECTORY_MOVED_FROM;
}
- move_list = g_slist_remove (move_list, tmp->data);
+ tracker_db_insert_pending_file (main_thread_db_con,
+ moved_from_info->file_id,
+ moved_from_info->uri,
+ moved_to_info->uri,
+ moved_from_info->mime,
+ 0,
+ action,
+ is_dir,
+ TRUE,
+ -1);
- return;
+ move_list = g_slist_remove (move_list, l->data);
+ item_removed = TRUE;
}
}
- /* matching pair not found so treat as a create action */
- g_debug ("no matching pair found for inotify move event for %s",
+ /* FIXME: Shouldn't we be freeing the moved_from_info
+ * here? -mr
+ */
+ if (item_removed) {
+ break;
+ }
+
+ /* Matching pair not found so treat as a create action */
+ g_debug ("No matching pair found for inotify move event for %s",
info->uri);
+
if (tracker_file_is_directory (info->uri)) {
info->action = TRACKER_DB_ACTION_DIRECTORY_CREATED;
} else {
info->action = TRACKER_DB_ACTION_WRITABLE_FILE_CLOSED;
}
- tracker_db_insert_pending_file (main_thread_db_con, info->file_id, info->uri, NULL, info->mime, 10, info->action, info->is_directory, TRUE, -1);
- tracker_db_file_info_free (info);
- return;
- } else if (action == TRACKER_DB_ACTION_WRITABLE_FILE_CLOSED) {
- tracker_add_io_grace (info->uri);
- g_message ("File:'%s' has finished changing", info->uri);
- tracker_db_insert_pending_file (main_thread_db_con, info->file_id, info->uri, NULL, info->mime, 0, info->action, info->is_directory, TRUE, -1);
+ tracker_db_insert_pending_file (main_thread_db_con,
+ info->file_id, info->uri,
+ NULL,
+ info->mime,
+ 10,
+ info->action,
+ info->is_directory,
+ TRUE,
+ -1);
tracker_db_file_info_free (info);
- return;
-
- }
-
- g_warning ("Not processing event:'%s' for uri:'%s'",
- tracker_db_action_to_string (info->action),
- info->uri);
- tracker_db_file_info_free (info);
-}
-
-
-static gboolean
-process_moved_events ()
-{
- const GSList *tmp;
-
- if (!tracker->is_running) {
- return FALSE;
- }
-
- if (!move_list) {
- return TRUE;
- }
-
- for (tmp = move_list; tmp; tmp = tmp->next) {
- TrackerDBFileInfo *info;
-
- info = (TrackerDBFileInfo *) tmp->data;
-
- /* make it a DELETE if we have not received a corresponding MOVED_TO event after a certain period */
- if ((info->counter < 1) && ((info->action == TRACKER_DB_ACTION_FILE_MOVED_FROM) || (info->action == TRACKER_DB_ACTION_DIRECTORY_MOVED_FROM))) {
+ break;
+ }
- /* make sure file no longer exists before issuing a "delete" */
-
- if (!tracker_file_is_valid (info->uri)) {
- if (info->action == TRACKER_DB_ACTION_DIRECTORY_MOVED_FROM) {
- process_event (info->uri, TRUE, TRACKER_DB_ACTION_DIRECTORY_DELETED, 0);
- } else {
- process_event (info->uri, FALSE, TRACKER_DB_ACTION_FILE_DELETED, 0);
- }
- }
+ case TRACKER_DB_ACTION_WRITABLE_FILE_CLOSED:
+ g_message ("File:'%s' has finished changing", info->uri);
- move_list = g_slist_remove (move_list, info);
- tracker_db_file_info_free (info);
- continue;
+ tracker_db_insert_pending_file (main_thread_db_con,
+ info->file_id,
+ info->uri,
+ NULL,
+ info->mime,
+ 0,
+ info->action,
+ info->is_directory,
+ TRUE,
+ -1);
+ tracker_db_file_info_free (info);
+ break;
- } else {
- info->counter--;
- }
+ default:
+ g_warning ("Not processing event:'%s' for uri:'%s'",
+ tracker_db_action_to_string (info->action),
+ info->uri);
+ tracker_db_file_info_free (info);
}
-
- if (!move_list)
- return FALSE;
-
- return TRUE;
}
-
static TrackerDBAction
get_event (guint32 event_type)
{
@@ -289,7 +322,6 @@
}
}
-
if (event_type & IN_MOVED_FROM) {
if (event_type & IN_ISDIR) {
return TRACKER_DB_ACTION_DIRECTORY_MOVED_FROM;
@@ -306,12 +338,10 @@
}
}
-
if (event_type & IN_CLOSE_WRITE) {
return TRACKER_DB_ACTION_WRITABLE_FILE_CLOSED;
}
-
if (event_type & IN_CREATE) {
if (event_type & IN_ISDIR) {
return TRACKER_DB_ACTION_DIRECTORY_CREATED;
@@ -326,20 +356,23 @@
static gboolean
process_inotify_events (void)
{
- while (g_queue_get_length (inotify_queue) > 0) {
+ while (g_queue_get_length (event_queue) > 0) {
TrackerDBResultSet *result_set;
- TrackerDBAction action_type;
- char *str = NULL, *filename = NULL, *monitor_name = NULL, *str_wd;
- char *file_utf8_uri = NULL, *dir_utf8_uri = NULL;
+ TrackerDBAction action_type;
+ gchar *str_wd;
+ gchar *str = NULL;
+ gchar *filename = NULL;
+ gchar *monitor_name = NULL;
+ gchar *file_utf8_uri = NULL;
+ gchar *dir_utf8_uri = NULL;
guint cookie;
-
struct inotify_event *event;
if (!tracker->is_running) {
return FALSE;
}
- event = g_queue_pop_head (inotify_queue);
+ event = g_queue_pop_head (event_queue);
if (!event) {
continue;
@@ -360,12 +393,13 @@
cookie = event->cookie;
- /* get watch name as monitor */
-
+ /* Get watch name as monitor */
str_wd = g_strdup_printf ("%d", event->wd);
- result_set = tracker_exec_proc (main_thread_db_con->cache, "GetWatchUri", str_wd, NULL);
-
+ result_set = tracker_exec_proc (main_thread_db_con->cache,
+ "GetWatchUri",
+ str_wd,
+ NULL);
g_free (str_wd);
if (result_set) {
@@ -382,7 +416,6 @@
}
if (tracker_is_empty_string (filename)) {
- //g_message ("WARNING: inotify event has no filename");
g_free (event);
continue;
}
@@ -390,7 +423,8 @@
file_utf8_uri = g_filename_to_utf8 (filename, -1, NULL, NULL, NULL);
if (tracker_is_empty_string (file_utf8_uri)) {
- g_critical ("file uri could not be converted to utf8 format");
+ g_critical ("File uri:'%s' could not be converted to utf8 format",
+ filename);
g_free (event);
continue;
}
@@ -399,85 +433,75 @@
str = g_strdup (file_utf8_uri);
dir_utf8_uri = NULL;
} else {
-
dir_utf8_uri = g_filename_to_utf8 (monitor_name, -1, NULL, NULL, NULL);
if (!dir_utf8_uri) {
- g_critical ("file uri could not be converted to utf8 format");
+ g_critical ("File uri:'%s' could not be converted to utf8 format",
+ monitor_name);
g_free (file_utf8_uri);
g_free (event);
continue;
}
- str = g_build_filename(dir_utf8_uri, file_utf8_uri, NULL);
+ str = g_build_filename (dir_utf8_uri, file_utf8_uri, NULL);
}
- if (str && str[0] == '/' &&
+ if (str && str[0] == G_DIR_SEPARATOR &&
(!tracker_process_files_should_be_ignored (str) ||
action_type == TRACKER_DB_ACTION_DIRECTORY_MOVED_FROM) &&
- tracker_process_files_should_be_crawled (tracker, str) &&
+ tracker_process_files_should_be_crawled (str) &&
tracker_process_files_should_be_watched (tracker->config, str)) {
process_event (str, tracker_file_is_directory (str), action_type, cookie);
} else {
- g_debug ("ignoring action %d on file %s", action_type, str);
- }
-
- if (monitor_name) {
- g_free (monitor_name);
- }
-
- if (str) {
- g_free (str);
+ g_debug ("Ignoring action:%d on file:'%s'",
+ action_type, str);
}
- if (file_utf8_uri) {
- g_free (file_utf8_uri);
- }
-
- if (dir_utf8_uri) {
- g_free (dir_utf8_uri);
- }
+ g_free (monitor_name);
+ g_free (str);
+ g_free (file_utf8_uri);
+ g_free (dir_utf8_uri);
g_free (event);
}
return FALSE;
}
-
static gboolean
-inotify_watch_func (GIOChannel *source, GIOCondition condition, gpointer data)
-{
- char buffer[16384];
- size_t buffer_i;
- size_t r;
- int fd;
+inotify_watch_func (GIOChannel *source,
+ GIOCondition condition,
+ gpointer data)
+{
+ gchar buffer[16384];
+ size_t i;
+ size_t bytes_read;
+ gint fd;
fd = g_io_channel_unix_get_fd (source);
+ bytes_read = read (fd, buffer, 16384);
- r = read (fd, buffer, 16384);
-
- if (r <= 0) {
- g_critical ("inotify system failure - unable to watch files");
+ if (bytes_read <= 0) {
+ g_critical ("Unable to watch files with inotify, read() failed on file descriptor");
return FALSE;
}
- buffer_i = 0;
+ i = 0;
- while (buffer_i < (size_t)r) {
- struct inotify_event *pevent, *event;
- size_t event_size;
+ while (i < (size_t) bytes_read) {
+ struct inotify_event *p;
+ struct inotify_event *event;
+ size_t event_size;
/* Parse events and process them ! */
-
if (!tracker->is_running) {
return FALSE;
}
- pevent = (struct inotify_event *) &buffer[buffer_i];
- event_size = sizeof (struct inotify_event) + pevent->len;
- event = g_memdup (pevent, event_size);
- g_queue_push_tail (inotify_queue, event);
- buffer_i += event_size;
+ p = (struct inotify_event*) &buffer[i];
+ event_size = sizeof (struct inotify_event) + p->len;
+ event = g_memdup (p, event_size);
+ g_queue_push_tail (event_queue, event);
+ i += event_size;
}
g_idle_add ((GSourceFunc) process_inotify_events, NULL);
@@ -485,100 +509,131 @@
return TRUE;
}
-
gboolean
-tracker_start_watching (void)
+tracker_watcher_init (void)
{
- g_return_val_if_fail (inotify_monitor_fd == -1, FALSE);
-
- inotify_monitor_fd = inotify_init ();
+ gchar *str;
- g_return_val_if_fail (inotify_monitor_fd >= 0, FALSE);
+ if (monitor_fd != -1) {
+ return TRUE;
+ }
+
+ monitor_fd = inotify_init ();
+
+ if (monitor_fd == -1) {
+ g_critical ("Could not initialize file watching, inotify_init() failed");
+ return FALSE;
+ }
+
+ event_queue = g_queue_new ();
+
+ /* We don't really care if we couldn't read from this file, in
+ * that case we assume a set value.
+ */
+ if (g_file_get_contents (INOTIFY_WATCH_LIMIT, &str, NULL, NULL)) {
+ /* Leave 500 watches for other users and make sure we don't
+ * reply with a negative value
+ */
+ monitor_limit = MAX (atoi (str) - 500, 500);
+ g_free (str);
+ }
+
+ g_message ("Using inotify monitor limit of %d", monitor_limit);
+
+ channel = g_io_channel_unix_new (monitor_fd);
+ g_io_add_watch (channel, G_IO_IN, inotify_watch_func, NULL);
+ g_io_channel_set_flags (channel, G_IO_FLAG_NONBLOCK, NULL);
- inotify_queue = g_queue_new ();
-
- if (tracker->watch_limit == 0) {
- tracker->watch_limit = 8191;
- if (g_file_test (INOTIFY_WATCH_LIMIT, G_FILE_TEST_EXISTS)) {
- gchar *limit;
- gsize size;
- if (g_file_get_contents (INOTIFY_WATCH_LIMIT, &limit, &size, NULL)) {
+ return TRUE;
+}
- /* leave 500 watches for other users */
- tracker->watch_limit = atoi (limit) - 500;
+void
+tracker_watcher_shutdown (void)
+{
+ g_slist_foreach (move_list, (GFunc) tracker_db_file_info_free, NULL);
+ g_slist_free (move_list);
+ move_list = NULL;
- g_message ("Setting inotify watch limit to %d.", tracker->watch_limit);
- g_free (limit);
- }
- }
+ if (channel) {
+ g_io_channel_shutdown (channel, TRUE, NULL);
+ channel = NULL;
}
- gio = g_io_channel_unix_new (inotify_monitor_fd);
- g_io_add_watch (gio, G_IO_IN, inotify_watch_func, NULL);
- g_io_channel_set_flags (gio, G_IO_FLAG_NONBLOCK, NULL);
-
- /* periodically process unmatched moved_from events */
+ g_queue_free (event_queue);
+ event_queue = NULL;
- return TRUE;
-}
-
-
-int
-tracker_count_watch_dirs (void)
-{
- return inotify_count;
+ monitor_fd = -1;
}
-
gboolean
-tracker_add_watch_dir (const char *dir, DBConnection *db_con)
+tracker_watcher_add_dir (const gchar *dir,
+ DBConnection *db_con)
{
- char *dir_in_locale;
- static gboolean limit_exceeded_msg = FALSE;
+ gchar *dir_in_locale;
+ static gboolean limit_exceeded = FALSE;
- g_return_val_if_fail (dir, FALSE);
- g_return_val_if_fail (dir[0] == '/', FALSE);
+ g_return_val_if_fail (dir != NULL, FALSE);
+ g_return_val_if_fail (dir[0] == G_DIR_SEPARATOR, FALSE);
if (!tracker->is_running) {
return FALSE;
}
- if (tracker_is_directory_watched (dir, db_con)) {
+ if (tracker_watcher_is_dir_watched (dir, db_con)) {
return FALSE;
}
- if (tracker_count_watch_dirs () >= (int) tracker->watch_limit) {
-
- if (!limit_exceeded_msg) {
- g_message ("Inotify Watch Limit has been exceeded - for best results you should increase number of inotify watches on your system");
- limit_exceeded_msg = TRUE;
+ if (tracker_watcher_get_dir_count () >= monitor_limit) {
+ if (!limit_exceeded) {
+ g_warning ("The directory watch limit (%d) has been reached, "
+ "you should increase the number of inotify watches on your system",
+ monitor_limit);
+ limit_exceeded = TRUE;
}
return FALSE;
- }
+ } else {
+ /* We should set this to FALSE in case we remove
+ * watches and then add some which exceed the limit
+ * again.
+ */
+ limit_exceeded = FALSE;
+ }
dir_in_locale = g_filename_from_utf8 (dir, -1, NULL, NULL, NULL);
- /* check directory permissions are okay */
- if (g_access (dir_in_locale, F_OK) == 0 && g_access (dir_in_locale, R_OK) == 0) {
- const guint32 mask = (IN_CLOSE_WRITE | IN_MOVE | IN_CREATE | IN_DELETE| IN_DELETE_SELF | IN_MOVE_SELF);
- int wd;
- char *str_wd;
-
- wd = inotify_add_watch (inotify_monitor_fd, dir_in_locale, mask);
+ /* Check directory permissions are okay */
+ if (g_access (dir_in_locale, F_OK) == 0 &&
+ g_access (dir_in_locale, R_OK) == 0) {
+ gchar *str_wd;
+ gint wd;
+ guint32 mask;
+
+ mask = 0;
+ mask |= IN_CLOSE_WRITE;
+ mask |= IN_MOVE;
+ mask |= IN_CREATE;
+ mask |= IN_DELETE;
+ mask |= IN_DELETE_SELF;
+ mask |= IN_MOVE_SELF;
+ wd = inotify_add_watch (monitor_fd, dir_in_locale, mask);
g_free (dir_in_locale);
if (wd < 0) {
- g_critical ("Inotify watch on %s has failed", dir);
+ g_critical ("Could not watch directory:'%s', inotify_add_watch() failed",
+ dir);
return FALSE;
}
str_wd = g_strdup_printf ("%d", wd);
tracker_exec_proc (db_con->cache, "InsertWatch", dir, str_wd, NULL);
g_free (str_wd);
- inotify_count++;
- g_message ("Watching directory %s (total watches = %d)", dir, inotify_count);
+
+ monitor_count++;
+ g_message ("Watching directory:'%s' (total = %d)",
+ dir, monitor_count);
+
return TRUE;
}
@@ -587,22 +642,26 @@
return FALSE;
}
-
-static gboolean
-delete_watch (const char *dir, DBConnection *db_con)
+void
+tracker_watcher_remove_dir (const gchar *dir,
+ gboolean delete_subdirs,
+ DBConnection *db_con)
{
TrackerDBResultSet *result_set;
- int wd;
+ gboolean valid = TRUE;
+ gint wd;
- g_return_val_if_fail (dir != NULL && dir[0] == G_DIR_SEPARATOR, FALSE);
+ g_return_if_fail (dir != NULL);
+ g_return_if_fail (dir[0] == G_DIR_SEPARATOR);
result_set = tracker_exec_proc (db_con->cache, "GetWatchID", dir, NULL);
wd = -1;
if (!result_set) {
- g_message ("WARNING: watch id not found for uri %s", dir);
- return FALSE;
+ g_message ("Could not find watch ID in the database for:'%s'",
+ dir);
+ return;
}
tracker_db_result_set_get (result_set, 0, &wd, -1);
@@ -611,33 +670,16 @@
tracker_exec_proc (db_con->cache, "DeleteWatch", dir, NULL);
if (wd > -1) {
- inotify_rm_watch (inotify_monitor_fd, wd);
- inotify_count--;
+ inotify_rm_watch (monitor_fd, wd);
+ monitor_count--;
}
- return TRUE;
-}
-
-
-void
-tracker_remove_watch_dir (const char *dir, gboolean delete_subdirs, DBConnection *db_con)
-{
- TrackerDBResultSet *result_set;
- gboolean valid = TRUE;
- int wd;
-
- g_return_if_fail (dir != NULL && dir[0] == G_DIR_SEPARATOR);
-
- delete_watch (dir, db_con);
-
if (!delete_subdirs) {
return;
}
result_set = tracker_db_get_sub_watches (db_con, dir);
- wd = -1;
-
if (!result_set) {
return;
}
@@ -650,19 +692,42 @@
continue;
}
- inotify_rm_watch (inotify_monitor_fd, wd);
- inotify_count--;
+ inotify_rm_watch (monitor_fd, wd);
+ monitor_count--;
}
g_object_unref (result_set);
tracker_db_delete_sub_watches (db_con, dir);
}
-
-void
-tracker_end_watching (void)
+gboolean
+tracker_watcher_is_dir_watched (const char *dir,
+ DBConnection *db_con)
{
- if (gio) {
- g_io_channel_shutdown (gio, TRUE, NULL);
+ TrackerDBResultSet *result_set;
+ gint id;
+
+ g_return_val_if_fail (dir != NULL, FALSE);
+ g_return_val_if_fail (dir[0] == G_DIR_SEPARATOR, FALSE);
+
+ if (!tracker->is_running) {
+ return FALSE;
+ }
+
+ result_set = tracker_exec_proc (db_con->cache, "GetWatchID", dir, NULL);
+
+ if (!result_set) {
+ return FALSE;
}
+
+ tracker_db_result_set_get (result_set, 0, &id, -1);
+ g_object_unref (result_set);
+
+ return id >= 0;
+}
+
+gint
+tracker_watcher_get_dir_count (void)
+{
+ return monitor_count;
}
Modified: branches/indexer-split/src/trackerd/tracker-main.c
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-main.c (original)
+++ branches/indexer-split/src/trackerd/tracker-main.c Mon Jun 2 16:55:23 2008
@@ -46,7 +46,6 @@
#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"
@@ -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/indexer-split/src/trackerd/tracker-main.h
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-main.h (original)
+++ branches/indexer-split/src/trackerd/tracker-main.h Mon Jun 2 16:55:23 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/indexer-split/src/trackerd/tracker-process-files.c
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-process-files.c (original)
+++ branches/indexer-split/src/trackerd/tracker-process-files.c Mon Jun 2 16:55:23 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-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/indexer-split/src/trackerd/tracker-process-files.h
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-process-files.h (original)
+++ branches/indexer-split/src/trackerd/tracker-process-files.h Mon Jun 2 16:55:23 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/indexer-split/src/trackerd/tracker-utils.c
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-utils.c (original)
+++ branches/indexer-split/src/trackerd/tracker-utils.c Mon Jun 2 16:55:23 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/indexer-split/src/trackerd/tracker-watch.h
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-watch.h (original)
+++ branches/indexer-split/src/trackerd/tracker-watch.h Mon Jun 2 16:55:23 2008
@@ -25,16 +25,16 @@
G_BEGIN_DECLS
-gboolean tracker_start_watching (void);
-void tracker_end_watching (void);
-gboolean tracker_add_watch_dir (const char *dir,
- DBConnection *db_con);
-void tracker_remove_watch_dir (const char *dir,
- gboolean delete_subdirs,
- DBConnection *db_con);
-gboolean tracker_is_directory_watched (const char *dir,
- DBConnection *db_con);
-int tracker_count_watch_dirs (void);
+gboolean tracker_watcher_init (void);
+void tracker_watcher_shutdown (void);
+gboolean tracker_watcher_add_dir (const char *dir,
+ DBConnection *db_con);
+void tracker_watcher_remove_dir (const char *dir,
+ gboolean delete_subdirs,
+ DBConnection *db_con);
+gboolean tracker_watcher_is_dir_watched (const char *dir,
+ DBConnection *db_con);
+gint tracker_watcher_get_dir_count (void);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]