[tracker/drop-inotify] Fully remove inotify stuff



commit 77592a6969935736a75d5bbacd1e9ccc4b7eb099
Author: Aleksander Morgado <aleksander lanedo com>
Date:   Tue Jun 29 19:38:22 2010 +0200

    Fully remove inotify stuff

 configure.ac                           |   30 --
 src/Makefile.am                        |    5 -
 src/libinotify/.cvsignore              |    5 -
 src/libinotify/Makefile.am             |   24 -
 src/libinotify/inotify-handle.c        |  274 -----------
 src/libinotify/inotify-handle.h        |   57 ---
 src/libinotify/inotify-listhash.c      |  133 -----
 src/libinotify/inotify-listhash.h      |   35 --
 src/libinotify/inotify-log.h           |   52 --
 src/libinotify/inotify-monitor.c       |  412 ----------------
 src/libinotify/inotify-monitor.h       |   34 --
 src/libinotify/libinotify.h            |   27 -
 src/libtracker-miner/Makefile.am       |    5 -
 src/libtracker-miner/tracker-monitor.c |  821 +-------------------------------
 tests/libtracker-miner/Makefile.am     |    5 -
 tests/tracker-miner-fs/Makefile.am     |    6 -
 16 files changed, 7 insertions(+), 1918 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 6844c84..583633e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -692,35 +692,6 @@ if test "$native_win32" = "yes" ; then
 fi
 
 ####################################################################
-#  libinotify
-####################################################################
-
-AC_ARG_ENABLE(libinotify,
-              AS_HELP_STRING([--enable-libinotify],
-                             [enables libinotify for the filesystem monitoring [[default=yes]]]),,
-              [enable_libinotify=yes])
-
-if test "x$enable_libinotify" != "xno"; then
-   AC_CHECK_HEADERS([sys/inotify.h],[have_libinotify=yes],[have_libinotify=no])
-
-   AM_CONDITIONAL(HAVE_LIBINOTIFY, test "$have_libinotify" = "yes")
-
-   if test "$have_libinotify" = "yes" ; then
-      AC_DEFINE(HAVE_LIBINOTIFY, 1, [Have libinotify])
-   fi
-else
-   have_libinotify="no  (disabled)"
-fi
-
-AM_CONDITIONAL(HAVE_LIBINOTIFY, test "$have_libinotify" = "yes")
-
-if test "$have_libinotify" = "yes" ; then
-  have_file_monitor="libinotify"
-else
-  have_file_monitor="gio"
-fi
-
-####################################################################
 #  SQLite check
 ####################################################################
 
@@ -1989,7 +1960,6 @@ Build Configuration:
 	Support for ioprio:                     $tracker_cv_have_ioprio
 	Support for HAL:                        $have_hal
 	Support for UPower:                     $have_upower
-	Support for file monitoring:            $have_file_monitor
 	Support for Cyrillic languages (enca):  $have_enca
 	Support for network status detection:   $have_network_manager
 	Unicode support library:                $with_unicode_support
diff --git a/src/Makefile.am b/src/Makefile.am
index 6043e11..0bbccf4 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,9 +1,5 @@
 include $(top_srcdir)/Makefile.decl
 
-if HAVE_LIBINOTIFY
-libinotify_dir = libinotify
-endif
-
 if HAVE_TRACKER_FTS
 libstemmer_dir = libstemmer
 endif
@@ -15,7 +11,6 @@ endif
 
 SUBDIRS = 					\
 	$(libstemmer_dir)			\
-	$(libinotify_dir)			\
 	libtracker-common 			\
 	libtracker-client			\
 	$(libtrackerfts_dir)			\
diff --git a/src/libtracker-miner/Makefile.am b/src/libtracker-miner/Makefile.am
index 1a7d9c1..ca3b003 100644
--- a/src/libtracker-miner/Makefile.am
+++ b/src/libtracker-miner/Makefile.am
@@ -68,11 +68,6 @@ libtracker_miner_ TRACKER_API_VERSION@_la_LIBADD = 	\
 	$(GCOV_LIBS)					\
 	$(GLIB2_LIBS)
 
-if HAVE_LIBINOTIFY
-libtracker_miner_ TRACKER_API_VERSION@_la_LIBADD +=	\
-	$(top_builddir)/src/libinotify/libinotify.la
-endif
-
 if HAVE_GNOME_KEYRING
 libtracker_miner_ TRACKER_API_VERSION@_la_SOURCES += 	\
 	tracker-password-provider-gnome.c
diff --git a/src/libtracker-miner/tracker-monitor.c b/src/libtracker-miner/tracker-monitor.c
index 4c510eb..fb032c7 100644
--- a/src/libtracker-miner/tracker-monitor.c
+++ b/src/libtracker-miner/tracker-monitor.c
@@ -21,13 +21,7 @@
 
 #include <stdlib.h>
 #include <string.h>
-
-#ifdef HAVE_LIBINOTIFY
-#  include <sys/inotify.h>
-#  include <libinotify/libinotify.h>
-#else
-#  include <gio/gio.h>
-#endif /* HAVE_LIBINOTIFY */
+#include <gio/gio.h>
 
 #include <libtracker-common/tracker-keyfile-object.h>
 
@@ -75,19 +69,8 @@ struct TrackerMonitorPrivate {
 
 	GHashTable    *event_pairs;
 	guint          event_pairs_timeout_id;
-
-#ifdef HAVE_LIBINOTIFY
-	GHashTable    *cached_events;
-	guint          cached_events_timeout_id;
-#endif /* HAVE_LIBINOTIFY */
 };
 
-#ifdef HAVE_LIBINOTIFY
-typedef INotifyHandle DirMonitor;
-#else
-typedef GFileMonitor DirMonitor;
-#endif /* HAVE_LIBINOTIFY */
-
 typedef struct {
 	GFile    *file;
 	GTimeVal  start_time;
@@ -120,9 +103,9 @@ static void           tracker_monitor_get_property (GObject        *object,
                                                     GValue         *value,
                                                     GParamSpec     *pspec);
 static guint          get_inotify_limit            (void);
-static DirMonitor *   directory_monitor_new        (TrackerMonitor *monitor,
+static GFileMonitor * directory_monitor_new        (TrackerMonitor *monitor,
 						    GFile          *file);
-static void           directory_monitor_cancel     (DirMonitor     *dir_monitor);
+static void           directory_monitor_cancel     (GFileMonitor     *dir_monitor);
 
 
 static void           event_data_free              (gpointer        data);
@@ -223,11 +206,9 @@ static void
 tracker_monitor_init (TrackerMonitor *object)
 {
 	TrackerMonitorPrivate *priv;
-#ifndef HAVE_LIBINOTIFY
 	GFile                 *file;
 	GFileMonitor          *monitor;
 	const gchar           *name;
-#endif /* HAVE_LIBINOTIFY */
 
 	object->private = TRACKER_MONITOR_GET_PRIVATE (object);
 
@@ -243,30 +224,6 @@ tracker_monitor_init (TrackerMonitor *object)
 		                       (GDestroyNotify) g_object_unref,
 		                       (GDestroyNotify) directory_monitor_cancel);
 
-#ifdef HAVE_LIBINOTIFY
-	/* We have a hash table with cookies so we can pair up move
-	 * events.
-	 */
-	priv->event_pairs =
-		g_hash_table_new_full (g_direct_hash,
-		                       g_direct_equal,
-		                       NULL,
-		                       event_data_free);
-
-	/* We have a hash table for events so we don't flood the
-	 * indexer with the same events too frequently, we also
-	 * concatenate some events with this like CREATED+UPDATED.
-	 */
-	priv->cached_events =
-		g_hash_table_new_full (g_file_hash,
-		                       (GEqualFunc) g_file_equal,
-		                       g_object_unref,
-		                       event_data_free);
-
-	g_message ("Monitor backend is libinotify");
-
-	priv->monitor_limit = get_inotify_limit ();
-#else /* HAVE_LIBINOTIFY */
 	priv->event_pairs =
 		g_hash_table_new_full (g_file_hash,
 				       (GEqualFunc) g_file_equal,
@@ -351,7 +308,6 @@ tracker_monitor_init (TrackerMonitor *object)
 	g_file_monitor_cancel (monitor);
 	g_object_unref (monitor);
 	g_object_unref (file);
-#endif /* !HAVE_LIBINOTIFY */
 
 	g_message ("Monitor limit is %d", priv->monitor_limit);
 }
@@ -369,18 +325,6 @@ tracker_monitor_finalize (GObject *object)
 	}
 #endif /* PAUSE_ON_IO */
 
-#ifdef HAVE_LIBINOTIFY
-	if (priv->cached_events_timeout_id) {
-		g_source_remove (priv->cached_events_timeout_id);
-	}
-
-	if (priv->event_pairs_timeout_id) {
-		g_source_remove (priv->event_pairs_timeout_id);
-	}
-
-	g_hash_table_unref (priv->cached_events);
-#endif /* HAVE_LIBINOTIFY */
-
 	g_hash_table_unref (priv->event_pairs);
 	g_hash_table_unref (priv->monitors);
 
@@ -540,8 +484,6 @@ event_data_free (gpointer data)
 	g_slice_free (EventData, data);
 }
 
-
-/* Note: used both when compiling with and without libinotify support */
 static gboolean
 tracker_monitor_move (TrackerMonitor *monitor,
                       GFile          *old_file,
@@ -635,753 +577,6 @@ tracker_monitor_move (TrackerMonitor *monitor,
 	return items_moved > 0;
 }
 
-#ifdef HAVE_LIBINOTIFY
-
-static void
-event_data_update (EventData *event)
-{
-	GTimeVal now;
-
-	g_get_current_time (&now);
-
-	event->last_time = now;
-}
-
-static gchar *
-libinotify_monitor_event_to_string (guint32 event_type)
-{
-	GString *s;
-
-	s = g_string_new ("");
-
-	if (event_type & IN_ACCESS) {
-		s = g_string_append (s, "IN_ACCESS | ");
-	}
-	if (event_type & IN_MODIFY) {
-		s = g_string_append (s, "IN_MODIFY | ");
-	}
-	if (event_type & IN_ATTRIB) {
-		s = g_string_append (s, "IN_ATTRIB | ");
-	}
-	if (event_type & IN_CLOSE_WRITE) {
-		s = g_string_append (s, "IN_CLOSE_WRITE | ");
-	}
-	if (event_type & IN_CLOSE_NOWRITE) {
-		s = g_string_append (s, "IN_CLOSE_NOWRITE | ");
-	}
-	if (event_type & IN_OPEN) {
-		s = g_string_append (s, "IN_OPEN | ");
-	}
-	if (event_type & IN_MOVED_FROM) {
-		s = g_string_append (s, "IN_MOVED_FROM | ");
-	}
-	if (event_type & IN_MOVED_TO) {
-		s = g_string_append (s, "IN_MOVED_TO | ");
-	}
-	if (event_type & IN_CREATE) {
-		s = g_string_append (s, "IN_CREATE | ");
-	}
-	if (event_type & IN_DELETE) {
-		s = g_string_append (s, "IN_DELETE | ");
-	}
-	if (event_type & IN_DELETE_SELF) {
-		s = g_string_append (s, "IN_DELETE_SELF | ");
-	}
-	if (event_type & IN_MOVE_SELF) {
-		s = g_string_append (s, "IN_MOVE_SELF | ");
-	}
-	if (event_type & IN_UNMOUNT) {
-		s = g_string_append (s, "IN_UNMOUNT | ");
-	}
-	if (event_type & IN_Q_OVERFLOW) {
-		s = g_string_append (s, "IN_Q_OVERFLOW | ");
-	}
-	if (event_type & IN_IGNORED) {
-		s = g_string_append (s, "IN_IGNORED | ");
-	}
-
-	/* helper events */
-	if (event_type & IN_CLOSE) {
-		s = g_string_append (s, "IN_CLOSE* | ");
-	}
-	if (event_type & IN_MOVE) {
-		s = g_string_append (s, "IN_MOVE* | ");
-	}
-
-	/* special flags */
-	if (event_type & IN_MASK_ADD) {
-		s = g_string_append (s, "IN_MASK_ADD^ | ");
-	}
-	if (event_type & IN_ISDIR) {
-		s = g_string_append (s, "IN_ISDIR^ | ");
-	}
-	if (event_type & IN_ONESHOT) {
-		s = g_string_append (s, "IN_ONESHOT^ | ");
-	}
-
-	s->str[s->len - 3] = '\0';
-
-	return g_string_free (s, FALSE);
-}
-
-static gboolean
-libinotify_event_pairs_timeout_cb (gpointer data)
-{
-	TrackerMonitor *monitor;
-	GTimeVal        now;
-	GHashTableIter  iter;
-	gpointer        key, value;
-
-	monitor = data;
-
-	g_debug ("Checking for event pairs which have timed out...");
-
-	g_get_current_time (&now);
-
-	g_hash_table_iter_init (&iter, monitor->private->event_pairs);
-	while (g_hash_table_iter_next (&iter, &key, &value)) {
-		EventData   *event;
-		glong        seconds;
-		glong        seconds_then;
-		gboolean     is_directory;
-
-		event = value;
-
-		seconds_then = event->start_time.tv_sec;
-
-		seconds  = now.tv_sec;
-		seconds -= seconds_then;
-
-		g_debug ("Comparing now:%ld to then:%ld, diff:%ld",
-		         now.tv_sec,
-		         seconds_then,
-		         seconds);
-
-		if (seconds < 2) {
-			continue;
-		}
-
-		/* We didn't receive an event pair for this
-		 * cookie, so we just generate the CREATE or
-		 * DELETE event for the file we know about.
-		 */
-		g_debug ("Event:%d with cookie:%d has timed out (%ld seconds have elapsed)",
-		         event->event_type,
-		         GPOINTER_TO_UINT (key),
-		         seconds);
-
-		is_directory = check_is_directory (monitor, event->file);
-
-		switch (event->event_type) {
-		case IN_MOVED_FROM:
-		case IN_DELETE:
-		case IN_DELETE_SELF:
-			/* So we knew the source, but not the
-			 * target location for the event.
-			 */
-			if (is_directory) {
-				tracker_monitor_remove (monitor,
-				                        event->file);
-			}
-
-			g_signal_emit (monitor,
-			               signals[ITEM_DELETED], 0,
-			               event->file,
-			               is_directory);
-			break;
-
-		case IN_CREATE:
-		case IN_MOVED_TO:
-			/* So we knew the target, but not the
-			 * source location for the event.
-			 */
-			g_signal_emit (monitor,
-			               signals[ITEM_CREATED], 0,
-			               event->file,
-			               is_directory);
-			break;
-		default:
-			break;
-		}
-		/* Clean up */
-		g_hash_table_iter_remove (&iter);
-	}
-
-	if (g_hash_table_size (monitor->private->event_pairs) < 1) {
-		g_debug ("No more events to pair, removing timeout");
-		monitor->private->event_pairs_timeout_id = 0;
-		return FALSE;
-	}
-
-	return TRUE;
-}
-
-static void
-libinotify_cached_event_handle (TrackerMonitor *monitor,
-                                EventData      *data,
-                                gboolean        is_directory)
-{
-	switch (data->event_type) {
-	case IN_MODIFY:
-	case IN_CLOSE_WRITE:
-	case IN_ATTRIB:
-		g_signal_emit (monitor,
-		               signals[ITEM_UPDATED], 0,
-		               data->file,
-		               is_directory);
-		break;
-
-	case IN_MOVED_FROM:
-		/* So we knew the source, but not the
-		 * target location for the event.
-		 */
-
-	case IN_DELETE:
-	case IN_DELETE_SELF:
-		if (is_directory) {
-			tracker_monitor_remove (monitor,
-			                        data->file);
-		}
-
-		g_signal_emit (monitor,
-		               signals[ITEM_DELETED], 0,
-		               data->file,
-		               is_directory);
-
-		break;
-
-	case IN_MOVED_TO:
-		/* So we new the target, but not the
-		 * source location for the event.
-		 */
-
-	case IN_CREATE:
-		g_signal_emit (monitor,
-		               signals[ITEM_CREATED], 0,
-		               data->file,
-		               is_directory);
-
-		break;
-	default:
-		break;
-	}
-}
-
-static gboolean
-libinotify_cached_events_timeout_cb (gpointer data)
-{
-	TrackerMonitor *monitor;
-	GTimeVal        now;
-	GHashTableIter  iter;
-	gpointer        key, value;
-
-	monitor = data;
-
-	g_debug ("Checking for cached events that have timed out...");
-
-	g_get_current_time (&now);
-
-	g_hash_table_iter_init (&iter, monitor->private->cached_events);
-	while (g_hash_table_iter_next (&iter, &key, &value)) {
-		EventData   *event;
-		glong        last_event_seconds;
-		glong        start_event_seconds;
-		gboolean     is_directory;
-		gboolean     force_emit = FALSE;
-		gboolean     timed_out = FALSE;
-
-		event = value;
-
-		last_event_seconds = now.tv_sec - event->last_time.tv_sec;
-		start_event_seconds = now.tv_sec - event->start_time.tv_sec;
-
-		is_directory = check_is_directory (monitor, event->file);
-
-		g_debug ("Comparing now:%ld to then:%ld (start:%ld), diff:%ld (with start:%ld)",
-		         now.tv_sec,
-		         event->last_time.tv_sec,
-		         event->start_time.tv_sec,
-		         last_event_seconds,
-		         start_event_seconds);
-
-		/* If the item has been in the cache for too long
-		 * according to the module config options, then we
-		 * force the cache to expire in order to not starve
-		 * the indexer of events for files which are ALWAYS
-		 * changing.
-		 */
-		if (monitor->private->cache_timeout > 0) {
-			force_emit = start_event_seconds > monitor->private->cache_timeout;
-		}
-
-		timed_out = last_event_seconds >= MAX (CACHE_LIFETIME_SECONDS,
-		                                       monitor->private->scan_timeout);
-
-		/* Make sure the item is in the cache for at least 2
-		 * seconds OR the time as stated by the module config
-		 * options. This way, always changing files can not
-		 * be emitted too and flood the indexer with events.
-		 */
-		if (!force_emit) {
-			if (!timed_out) {
-				continue;
-			}
-
-			/* We didn't receive an event pair for this
-			 * cookie, so we just generate the CREATE or
-			 * DELETE event for the file we know about.
-			 */
-			g_debug ("Cached event:%d has timed out (%ld seconds have elapsed)",
-			         event->event_type,
-			         last_event_seconds);
-		} else {
-			event->start_time = now;
-			g_debug ("Cached event:%d has been forced to signal (%ld seconds have elapsed since the beginning)",
-			         event->event_type,
-			         start_event_seconds);
-		}
-
-		/* Signal event */
-		libinotify_cached_event_handle (monitor,
-		                                event,
-		                                is_directory);
-
-
-		if (timed_out) {
-			/* Clean up */
-			g_hash_table_iter_remove (&iter);
-		} else {
-			if (event->event_type == IN_CREATE) {
-				/* The file has been already created,
-				 * We want any further events to be
-				 * IN_MODIFY.
-				 */
-				event->event_type = IN_MODIFY;
-			}
-		}
-	}
-
-	if (g_hash_table_size (monitor->private->cached_events) < 1) {
-		g_debug ("No more cached events, removing timeout");
-		monitor->private->cached_events_timeout_id = 0;
-		return FALSE;
-	}
-
-	return TRUE;
-}
-
-static gboolean
-libinotify_cached_event_delete_children_func (gpointer key,
-                                              gpointer value,
-                                              gpointer user_data)
-{
-	EventData *data;
-
-	data = user_data;
-
-	return (data->event_type == IN_DELETE ||
-	        data->event_type == IN_DELETE_SELF) &&
-		g_file_has_prefix (key, data->file);
-}
-
-static void
-libinotify_monitor_force_emission (TrackerMonitor *monitor,
-                                   GFile          *file,
-                                   guint32         event_type,
-                                   gboolean        is_directory)
-{
-	EventData *data;
-
-	data = g_hash_table_lookup (monitor->private->cached_events, file);
-
-	if (data) {
-		gchar *event_type_str;
-
-		event_type_str = libinotify_monitor_event_to_string (event_type);
-
-		g_debug ("Cached event:%d being handled before %s",
-		         data->event_type,
-		         event_type_str);
-
-		/* Signal event */
-		libinotify_cached_event_handle (monitor,
-		                                data,
-		                                is_directory);
-
-		/* Clean up */
-		g_hash_table_remove (monitor->private->cached_events, data->file);
-
-		g_free (event_type_str);
-	}
-}
-
-static void
-libinotify_monitor_event_cb (INotifyHandle *handle,
-                             const char    *monitor_name,
-                             const char    *filename,
-                             guint32        event_type,
-                             guint32        cookie,
-                             gpointer       user_data)
-{
-	TrackerMonitor *monitor;
-	GFile          *file;
-	GFile          *other_file;
-	gchar          *str1;
-	gchar          *str2;
-	gboolean        is_directory;
-	gchar          *event_type_str;
-	EventData      *data = NULL;
-	gboolean        set_up_cache_timeout = FALSE;
-
-	monitor = user_data;
-
-	switch (event_type) {
-	case IN_Q_OVERFLOW:
-	case IN_OPEN:
-	case IN_CLOSE_NOWRITE:
-	case IN_ACCESS:
-	case IN_IGNORED:
-		/* Return, otherwise we spam with messages for every
-		 * file we open and look at.
-		 */
-		return;
-	default:
-		break;
-	}
-
-	if (G_UNLIKELY (!monitor->private->enabled)) {
-		g_debug ("Silently dropping monitor event, monitor disabled for now");
-		return;
-	}
-
-	if (monitor_name) {
-		str1 = g_build_filename (monitor_name, filename, NULL);
-		file = g_file_new_for_path (str1);
-	} else {
-		str1 = NULL;
-		file = g_file_new_for_path (filename);
-	}
-
-	other_file = NULL;
-	str2 = NULL;
-
-	if (!str1) {
-		str1 = g_file_get_path (file);
-	}
-
-	is_directory = check_is_directory (monitor, file);
-
-	event_type_str = libinotify_monitor_event_to_string (event_type);
-	g_message ("Received monitor event:%d->'%s' for file:'%s' (cookie:%d)",
-	           event_type,
-	           event_type_str,
-	           str1 ? str1 : "",
-	           cookie);
-	g_free (event_type_str);
-
-#ifdef PAUSE_ON_IO
-	if (monitor->private->unpause_timeout_id != 0) {
-		g_source_remove (monitor->private->unpause_timeout_id);
-	} else {
-		g_message ("Pausing indexing because we are "
-		           "receiving monitor events");
-
-		tracker_status_set_is_paused_for_io (TRUE);
-	}
-
-	monitor->private->unpause_timeout_id =
-		g_timeout_add_seconds (PAUSE_ON_IO_SECONDS,
-		                       unpause_cb,
-		                       monitor);
-#endif /* PAUSE_ON_IO */
-
-	if (cookie > 0) {
-		/* First check if we already have a file in
-		 * the event pairs hash table.
-		 */
-		data = g_hash_table_lookup (monitor->private->event_pairs,
-		                            GUINT_TO_POINTER (cookie));
-
-		if (!data) {
-			data = event_data_new (file, event_type);
-
-			g_hash_table_insert (monitor->private->event_pairs,
-			                     GUINT_TO_POINTER (cookie),
-			                     data);
-		} else {
-			other_file = data->file;
-		}
-
-		/* Add a check for old cookies we didn't
-		 * receive the follow up pair event for.
-		 */
-		if (!monitor->private->event_pairs_timeout_id) {
-			g_debug ("Setting up event pair timeout check");
-
-			monitor->private->event_pairs_timeout_id =
-				g_timeout_add_seconds (CACHE_LIFETIME_SECONDS,
-				                       libinotify_event_pairs_timeout_cb,
-				                       monitor);
-		}
-	}
-
-	switch (event_type) {
-	case IN_MODIFY:
-	case IN_CLOSE_WRITE:
-	case IN_ATTRIB:
-		set_up_cache_timeout = TRUE;
-
-		data = g_hash_table_lookup (monitor->private->cached_events, file);
-		if (data) {
-			/* We already have an event we will
-			 * signal when we timeout. So update
-			 * and don't propagate yet this event.
-			 *
-			 * See IN_CREATE.
-			 */
-			event_data_update (data);
-			break;
-		}
-
-		/* Here we just wait to make sure we don't get
-		 * any more MODIFY events and after 2 seconds
-		 * of no MODIFY events we emit it. This saves
-		 * spamming.
-		 */
-		data = event_data_new (file, event_type);
-
-		g_hash_table_insert (monitor->private->cached_events,
-		                     g_object_ref (data->file),
-		                     data);
-		break;
-
-	case IN_MOVED_FROM:
-		/* If the file is *ALREADY* in the cache, we need to
-		 * handle that cache first. Otherwise we have
-		 * disparity when the cache expires.
-		 */
-		libinotify_monitor_force_emission (monitor,
-		                                   file,
-		                                   event_type,
-		                                   is_directory);
-
-		/* Fall through */
-	case IN_DELETE:
-	case IN_DELETE_SELF:
-	case IN_UNMOUNT:
-		if (cookie == 0 || event_type == IN_UNMOUNT) {
-			/* This is how things generally work with
-			 * deleted items:
-			 *
-			 * 1. Check if we have a child file already in
-			 *    the deleted hash table AND this is a
-			 *    directory. If so, we delete all child
-			 *    items.
-			 * 2. Add the file to the deleted hash table
-			 *    but only if we don't have a higher level
-			 *    directory in the hash table already.
-			 * 3. Make sure we have the timeout set up to
-			 *    handle deleted items after n seconds.
-			 * 4. When we handle deleted items, only emit
-			 *    those which were deleted in the last 2
-			 *    seconds.
-			 */
-
-			data = event_data_new (file, event_type);
-
-			/* Stage 1: */
-			if (is_directory) {
-				gint count;
-
-				tracker_monitor_remove (monitor, file);
-
-				count =         g_hash_table_foreach_remove (monitor->private->cached_events,
-				                                             libinotify_cached_event_delete_children_func,
-				                                             data);
-
-				g_debug ("Removed %d child items in recently deleted cache", count);
-			}
-
-			/* Stage 2: */
-			g_hash_table_insert (monitor->private->cached_events,
-			                     g_object_ref (data->file),
-			                     data);
-
-			/* Stage 3: */
-			set_up_cache_timeout = TRUE;
-
-			/* FIXME: How do we handle the deleted items
-			 * cache for other events, i.e. we should
-			 * have something like
-			 * libinotify_monitor_force_emission() for
-			 * deleted items if we get CREATED before we
-			 * emit the DELETE event.
-			 */
-		} else if (other_file) {
-			g_signal_emit (monitor,
-			               signals[ITEM_MOVED], 0,
-			               file,
-			               other_file,
-			               is_directory,
-			               TRUE);
-
-			if (is_directory) {
-				tracker_monitor_move (monitor, file, other_file);
-			}
-
-			g_hash_table_remove (monitor->private->event_pairs,
-			                     GUINT_TO_POINTER (cookie));
-		}
-
-		break;
-
-	case IN_CREATE:
-		/* Here we just wait with CREATE events and
-		 * if we get MODIFY after, we drop the MODIFY
-		 * and just emit CREATE because otherwise we
-		 * send twice as much traffic to the indexer.
-		 */
-		set_up_cache_timeout = TRUE;
-
-		data = event_data_new (file, event_type);
-
-		g_hash_table_insert (monitor->private->cached_events,
-		                     g_object_ref (data->file),
-		                     data);
-		break;
-
-	case IN_MOVED_TO:
-		/* If the file is *ALREADY* in the cache, we need to
-		 * handle that cache first. Otherwise we have
-		 * disparity when the cache expires.
-		 */
-		libinotify_monitor_force_emission (monitor, file, event_type, is_directory);
-
-		/* Handle event */
-		if (cookie == 0) {
-			g_signal_emit (monitor,
-			               signals[ITEM_CREATED], 0,
-			               file,
-			               is_directory);
-		} else if (other_file) {
-			gboolean is_source_indexed;
-
-			/* We check for the event pair in the
-			 * hash table here. If it doesn't
-			 * exist even though we have a cookie
-			 * it means we didn't have a monitor
-			 * set up on the source location.
-			 * This means we need to get the
-			 * processor to crawl the new
-			 * location.
-			 */
-
-			if (g_hash_table_lookup (monitor->private->event_pairs,
-			                         GUINT_TO_POINTER (cookie))) {
-				is_source_indexed = TRUE;
-			} else {
-				is_source_indexed = FALSE;
-			}
-
-			g_signal_emit (monitor,
-			               signals[ITEM_MOVED], 0,
-			               other_file,
-			               file,
-			               is_directory,
-			               is_source_indexed);
-
-			if (is_directory) {
-				tracker_monitor_move (monitor, other_file, file);
-			}
-
-			g_hash_table_remove (monitor->private->event_pairs,
-			                     GUINT_TO_POINTER (cookie));
-		}
-
-		break;
-
-	case IN_MOVE_SELF:
-		/* We ignore this one because it is a
-		 * convenience state and we handle the
-		 * MOVE_TO and MOVE_FROM already.
-		 */
-
-	default:
-		break;
-	}
-
-	if (set_up_cache_timeout &&
-	    monitor->private->cached_events_timeout_id == 0) {
-		g_debug ("Setting up cached events timeout check");
-
-		monitor->private->cached_events_timeout_id =
-			g_timeout_add_seconds (CACHE_LIFETIME_SECONDS,
-			                       libinotify_cached_events_timeout_cb,
-			                       monitor);
-	}
-
-	g_free (str1);
-	g_free (str2);
-	g_object_unref (file);
-}
-
-static DirMonitor *
-directory_monitor_new (TrackerMonitor *monitor,
-		       GFile          *file)
-{
-	INotifyHandle *handle;
-	gchar         *path;
-	guint32        mask;
-	unsigned long  flags;
-
-	flags  = 0;
-	flags &= ~IN_FLAG_FILE_BASED;
-
-	/* Instead of use IN_ALL_EVENTS, we use these so we don't get
-	 * spammed with events on downloads and big copies between
-	 * directories.
-	 *
-	 * Missing now is:
-	 *   IN_ACCESS
-	 *   IN_MODIFY
-	 *   IN_CLOSE_NOWRITE
-	 *   IN_OPEN
-	 */
-	mask   = (IN_MOVED_FROM | IN_MOVED_TO | IN_MOVE_SELF |
-	          IN_DELETE | IN_DELETE_SELF |
-	          IN_CREATE |
-	          IN_CLOSE_WRITE |
-	          IN_ATTRIB |
-	          IN_UNMOUNT);
-
-	/* For files */
-	/* flags |= IN_FLAG_FILE_BASED; */
-
-	path = g_file_get_path (file);
-	handle = inotify_monitor_add (path,
-	                              mask,
-	                              flags,
-	                              libinotify_monitor_event_cb,
-	                              monitor);
-	g_free (path);
-
-	if (!handle) {
-		return NULL;
-	}
-
-	return handle;
-}
-
-static void
-directory_monitor_cancel (DirMonitor *dir_monitor)
-{
-	if (dir_monitor) {
-		inotify_monitor_remove (dir_monitor);
-	}
-}
-
-#else /* HAVE_LIBINOTIFY */
-
 static const gchar *
 monitor_event_to_string (GFileMonitorEvent event_type)
 {
@@ -1627,7 +822,7 @@ monitor_event_cb (GFileMonitor	    *file_monitor,
 	g_free (str2);
 }
 
-static DirMonitor *
+static GFileMonitor *
 directory_monitor_new (TrackerMonitor *monitor,
 		       GFile          *file)
 {
@@ -1663,7 +858,7 @@ directory_monitor_new (TrackerMonitor *monitor,
 }
 
 static void
-directory_monitor_cancel (DirMonitor *monitor)
+directory_monitor_cancel (GFileMonitor *monitor)
 {
 	if (monitor) {
 		g_file_monitor_cancel (G_FILE_MONITOR (monitor));
@@ -1671,8 +866,6 @@ directory_monitor_cancel (DirMonitor *monitor)
 	}
 }
 
-#endif /* HAVE_LIBINOTIFY */
-
 TrackerMonitor *
 tracker_monitor_new (void)
 {
@@ -1738,7 +931,7 @@ tracker_monitor_set_enabled (TrackerMonitor *monitor,
 		file = k->data;
 
 		if (enabled) {
-			DirMonitor *dir_monitor;
+			GFileMonitor *dir_monitor;
 
 			dir_monitor = directory_monitor_new (monitor, file);
 			g_hash_table_replace (monitor->private->monitors,
@@ -1793,7 +986,7 @@ gboolean
 tracker_monitor_add (TrackerMonitor *monitor,
                      GFile          *file)
 {
-	DirMonitor *dir_monitor = NULL;
+	GFileMonitor *dir_monitor = NULL;
 	gchar *path;
 
 	g_return_val_if_fail (TRACKER_IS_MONITOR (monitor), FALSE);
diff --git a/tests/libtracker-miner/Makefile.am b/tests/libtracker-miner/Makefile.am
index 3c0bae6..53f6e43 100644
--- a/tests/libtracker-miner/Makefile.am
+++ b/tests/libtracker-miner/Makefile.am
@@ -61,11 +61,6 @@ tracker_monitor_test_SOURCES =							\
 	$(libtracker_miner_marshal_sources)					\
 	$(libtracker_miner_monitor_sources)
 
-if HAVE_LIBINOTIFY
-tracker_monitor_test_LDADD =							\
-	$(top_builddir)/src/libinotify/libinotify.la
-endif
-
 tracker_miner_manager_test_VALASOURCES =					\
 	tracker-miner-mock.vala
 
diff --git a/tests/tracker-miner-fs/Makefile.am b/tests/tracker-miner-fs/Makefile.am
index f0706e5..772de8d 100644
--- a/tests/tracker-miner-fs/Makefile.am
+++ b/tests/tracker-miner-fs/Makefile.am
@@ -39,9 +39,3 @@ tracker_metadata_utils_LDADD =	                                        	\
 	$(GIO_LIBS)								\
 	$(GCOV_LIBS)								\
 	$(GLIB2_LIBS)
-
-
-if HAVE_LIBINOTIFY
-tracker_metadata_utils_LDADD +=							\
-	$(top_builddir)/src/libinotify/libinotify.la
-endif #HAVE_LIBINOTIFY



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]