[tracker/miner-fs-monitor-created-event-fixes: 1/3] libtracker-miner: minor coding style changes
- From: Aleksander Morgado <aleksm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/miner-fs-monitor-created-event-fixes: 1/3] libtracker-miner: minor coding style changes
- Date: Wed, 19 Jan 2011 13:58:25 +0000 (UTC)
commit 7db767fdb7e2f949b56930798da9e57eed6d3043
Author: Aleksander Morgado <aleksander lanedo com>
Date: Wed Jan 19 14:35:55 2011 +0100
libtracker-miner: minor coding style changes
src/libtracker-miner/tracker-monitor.c | 142 +++++++++++++++++++-------------
1 files changed, 84 insertions(+), 58 deletions(-)
---
diff --git a/src/libtracker-miner/tracker-monitor.c b/src/libtracker-miner/tracker-monitor.c
index 08c5fe7..d3b85ce 100644
--- a/src/libtracker-miner/tracker-monitor.c
+++ b/src/libtracker-miner/tracker-monitor.c
@@ -110,7 +110,7 @@ static void tracker_monitor_get_property (GObject *object,
GParamSpec *pspec);
static guint get_inotify_limit (void);
static GFileMonitor * directory_monitor_new (TrackerMonitor *monitor,
- GFile *file);
+ GFile *file);
static void directory_monitor_cancel (GFileMonitor *dir_monitor);
@@ -228,14 +228,14 @@ tracker_monitor_init (TrackerMonitor *object)
priv->pre_update =
g_hash_table_new_full (g_file_hash,
- (GEqualFunc) g_file_equal,
- (GDestroyNotify) g_object_unref,
- event_data_free);
+ (GEqualFunc) g_file_equal,
+ (GDestroyNotify) g_object_unref,
+ event_data_free);
priv->pre_delete =
g_hash_table_new_full (g_file_hash,
- (GEqualFunc) g_file_equal,
- (GDestroyNotify) g_object_unref,
- event_data_free);
+ (GEqualFunc) g_file_equal,
+ (GDestroyNotify) g_object_unref,
+ event_data_free);
/* For the first monitor we get the type and find out if we
* are using inotify, FAM, polling, etc.
@@ -432,7 +432,7 @@ unpause_cb (gpointer data)
static gboolean
check_is_directory (TrackerMonitor *monitor,
- GFile *file)
+ GFile *file)
{
GFileType file_type;
@@ -617,7 +617,7 @@ monitor_event_to_string (GFileMonitorEvent event_type)
static void
emit_signal_for_event (TrackerMonitor *monitor,
- EventData *event_data)
+ EventData *event_data)
{
switch (event_data->event_type) {
case G_FILE_MONITOR_EVENT_CREATED:
@@ -625,8 +625,8 @@ emit_signal_for_event (TrackerMonitor *monitor,
event_data->is_directory ? "DIRECTORY" : "FILE",
event_data->file_uri);
g_signal_emit (monitor,
- signals[ITEM_CREATED], 0,
- event_data->file,
+ signals[ITEM_CREATED], 0,
+ event_data->file,
event_data->is_directory);
/* Note that if the created item is a Directory, we must NOT
* add automatically a new monitor. */
@@ -638,9 +638,9 @@ emit_signal_for_event (TrackerMonitor *monitor,
event_data->is_directory ? "DIRECTORY" : "FILE",
event_data->file_uri);
g_signal_emit (monitor,
- signals[ITEM_UPDATED], 0,
- event_data->file,
- event_data->is_directory);
+ signals[ITEM_UPDATED], 0,
+ event_data->file,
+ event_data->is_directory);
break;
case G_FILE_MONITOR_EVENT_ATTRIBUTE_CHANGED:
@@ -648,9 +648,9 @@ emit_signal_for_event (TrackerMonitor *monitor,
event_data->is_directory ? "DIRECTORY" : "FILE",
event_data->file_uri);
g_signal_emit (monitor,
- signals[ITEM_ATTRIBUTE_UPDATED], 0,
- event_data->file,
- event_data->is_directory);
+ signals[ITEM_ATTRIBUTE_UPDATED], 0,
+ event_data->file,
+ event_data->is_directory);
break;
case G_FILE_MONITOR_EVENT_DELETED:
@@ -660,7 +660,7 @@ emit_signal_for_event (TrackerMonitor *monitor,
/* Remove monitors recursively */
if (event_data->is_directory) {
tracker_monitor_remove_recursively (monitor,
- event_data->file);
+ event_data->file);
}
g_signal_emit (monitor,
signals[ITEM_DELETED], 0,
@@ -717,23 +717,22 @@ event_pairs_process_in_ht (TrackerMonitor *monitor,
EventData *event_data = value;
glong seconds;
+ /* Event didn't expire yet, keep it */
seconds = now->tv_sec - event_data->start_time.tv_sec;
-
- if (seconds < 2) {
+ if (seconds < 2)
continue;
- } else {
- g_debug ("Event '%s' for URI '%s' has timed out (%ld seconds have elapsed)",
- monitor_event_to_string (event_data->event_type),
- event_data->file_uri,
- seconds);
- /* STEAL the item from the HT, so that disposal methods
- * for key and value are not called. */
- g_hash_table_iter_steal (&iter);
- /* Unref the key, as no longer needed */
- g_object_unref (key);
- /* Add the expired event to our temp list */
- expired_events = g_list_append (expired_events, event_data);
- }
+
+ g_debug ("Event '%s' for URI '%s' has timed out (%ld seconds have elapsed)",
+ monitor_event_to_string (event_data->event_type),
+ event_data->file_uri,
+ seconds);
+ /* STEAL the item from the HT, so that disposal methods
+ * for key and value are not called. */
+ g_hash_table_iter_steal (&iter);
+ /* Unref the key, as no longer needed */
+ g_object_unref (key);
+ /* Add the expired event to our temp list */
+ expired_events = g_list_append (expired_events, event_data);
}
for (l = expired_events; l; l = g_list_next (l)) {
@@ -771,11 +770,11 @@ event_pairs_timeout_cb (gpointer user_data)
}
static void
-monitor_event_cb (GFileMonitor *file_monitor,
- GFile *file,
- GFile *other_file,
+monitor_event_cb (GFileMonitor *file_monitor,
+ GFile *file,
+ GFile *other_file,
GFileMonitorEvent event_type,
- gpointer user_data)
+ gpointer user_data)
{
TrackerMonitor *monitor;
gchar *file_uri;
@@ -818,15 +817,15 @@ monitor_event_cb (GFileMonitor *file_monitor,
g_source_remove (monitor->private->unpause_timeout_id);
} else {
g_message ("Pausing indexing because we are "
- "receiving monitor events");
+ "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);
+ unpause_cb,
+ monitor);
#endif /* PAUSE_ON_IO */
if (!is_directory) {
@@ -840,7 +839,10 @@ monitor_event_cb (GFileMonitor *file_monitor,
*/
g_hash_table_replace (monitor->private->pre_update,
g_object_ref (file),
- event_data_new (file, NULL, FALSE, event_type));
+ event_data_new (file,
+ NULL,
+ FALSE,
+ G_FILE_MONITOR_EVENT_CREATED));
break;
}
@@ -904,7 +906,10 @@ monitor_event_cb (GFileMonitor *file_monitor,
/* Insert new update item in cache */
g_hash_table_insert (monitor->private->pre_update,
g_object_ref (file),
- event_data_new (file, NULL, FALSE, event_type));
+ event_data_new (file,
+ NULL,
+ FALSE,
+ G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT));
}
#else
/* If no blacklisting desired, emit event right away */
@@ -914,7 +919,10 @@ monitor_event_cb (GFileMonitor *file_monitor,
} else {
EventData *new_event;
- new_event = event_data_new (file, NULL, FALSE, event_type);
+ new_event = event_data_new (file,
+ NULL,
+ FALSE,
+ G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT);
emit_signal_for_event (monitor, new_event);
event_data_free (new_event);
}
@@ -946,7 +954,10 @@ monitor_event_cb (GFileMonitor *file_monitor,
}
#endif /* ENABLE_FILE_BLACKLISTING */
- new_event = event_data_new (file, NULL, FALSE, event_type);
+ new_event = event_data_new (file,
+ NULL,
+ FALSE,
+ G_FILE_MONITOR_EVENT_DELETED);
emit_signal_for_event (monitor, new_event);
event_data_free (new_event);
break;
@@ -1012,7 +1023,10 @@ monitor_event_cb (GFileMonitor *file_monitor,
}
#endif /* ENABLE_FILE_BLACKLISTING */
- new_event = event_data_new (file, other_file, FALSE, event_type);
+ new_event = event_data_new (file,
+ other_file,
+ FALSE,
+ G_FILE_MONITOR_EVENT_MOVED);
emit_signal_for_event (monitor, new_event);
event_data_free (new_event);
break;
@@ -1044,7 +1058,10 @@ monitor_event_cb (GFileMonitor *file_monitor,
if (!g_hash_table_lookup (monitor->private->pre_update, file)) {
g_hash_table_insert (monitor->private->pre_update,
g_object_ref (file),
- event_data_new (file, NULL, TRUE, event_type));
+ event_data_new (file,
+ NULL,
+ TRUE,
+ event_type));
}
break;
@@ -1077,7 +1094,10 @@ monitor_event_cb (GFileMonitor *file_monitor,
/* If no previous, add to HT */
g_hash_table_replace (monitor->private->pre_delete,
g_object_ref (file),
- event_data_new (file, NULL, TRUE, event_type));
+ event_data_new (file,
+ NULL,
+ TRUE,
+ G_FILE_MONITOR_EVENT_DELETED));
}
break;
@@ -1100,7 +1120,10 @@ monitor_event_cb (GFileMonitor *file_monitor,
previous_delete_event_data->event_type == G_FILE_MONITOR_EVENT_DELETED) {
EventData *new_event;
- new_event = event_data_new (file, other_file, TRUE, G_FILE_MONITOR_EVENT_MOVED);
+ new_event = event_data_new (file,
+ other_file,
+ TRUE,
+ G_FILE_MONITOR_EVENT_MOVED);
g_debug ("Processing DELETE(A) + MOVE(A->B) as MOVE(A->B) for directory '%s->%s'",
new_event->file_uri,
new_event->other_file_uri);
@@ -1114,7 +1137,10 @@ monitor_event_cb (GFileMonitor *file_monitor,
/* If no previous, add to HT */
g_hash_table_replace (monitor->private->pre_delete,
g_object_ref (file),
- event_data_new (file, other_file, TRUE, event_type));
+ event_data_new (file,
+ other_file,
+ TRUE,
+ G_FILE_MONITOR_EVENT_MOVED));
}
break;
@@ -1133,8 +1159,8 @@ monitor_event_cb (GFileMonitor *file_monitor,
g_debug ("Waiting for event pairs");
monitor->private->event_pairs_timeout_id =
g_timeout_add_seconds (CACHE_LIFETIME_SECONDS,
- event_pairs_timeout_cb,
- monitor);
+ event_pairs_timeout_cb,
+ monitor);
}
} else {
if (monitor->private->event_pairs_timeout_id != 0) {
@@ -1150,22 +1176,22 @@ monitor_event_cb (GFileMonitor *file_monitor,
static GFileMonitor *
directory_monitor_new (TrackerMonitor *monitor,
- GFile *file)
+ GFile *file)
{
GFileMonitor *file_monitor;
GError *error = NULL;
file_monitor = g_file_monitor_directory (file,
- G_FILE_MONITOR_SEND_MOVED | G_FILE_MONITOR_WATCH_MOUNTS,
- NULL,
- &error);
+ G_FILE_MONITOR_SEND_MOVED | G_FILE_MONITOR_WATCH_MOUNTS,
+ NULL,
+ &error);
if (error) {
gchar *uri;
uri = g_file_get_uri (file);
g_warning ("Could not add monitor for path:'%s', %s",
- uri, error->message);
+ uri, error->message);
g_error_free (error);
g_free (uri);
@@ -1174,8 +1200,8 @@ directory_monitor_new (TrackerMonitor *monitor,
}
g_signal_connect (file_monitor, "changed",
- G_CALLBACK (monitor_event_cb),
- monitor);
+ G_CALLBACK (monitor_event_cb),
+ monitor);
return file_monitor;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]