[tracker/miner-fs-monitor-improvements: 2/4] tracker-miner-fs: Treat ATTRIBUTE_CHANGED-only events independently
- From: Aleksander Morgado <aleksm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/miner-fs-monitor-improvements: 2/4] tracker-miner-fs: Treat ATTRIBUTE_CHANGED-only events independently
- Date: Tue, 21 Sep 2010 11:22:48 +0000 (UTC)
commit 6f5685b62c627927acf757a224ee4b2d05400e5e
Author: Aleksander Morgado <aleksander lanedo com>
Date: Tue Sep 21 09:53:54 2010 +0200
tracker-miner-fs: Treat ATTRIBUTE_CHANGED-only events independently
src/libtracker-miner/tracker-miner-fs.c | 44 +++++++++++++++++++++++++++++++
src/libtracker-miner/tracker-monitor.c | 23 +++++++++++++++-
2 files changed, 66 insertions(+), 1 deletions(-)
---
diff --git a/src/libtracker-miner/tracker-miner-fs.c b/src/libtracker-miner/tracker-miner-fs.c
index 6b6fbe4..2bab374 100644
--- a/src/libtracker-miner/tracker-miner-fs.c
+++ b/src/libtracker-miner/tracker-miner-fs.c
@@ -112,6 +112,7 @@ struct _TrackerMinerFSPrivate {
GHashTable *items_ignore_next_update;
GQuark quark_ignore_file;
+ GQuark quark_attribute_updated;
GList *config_directories;
@@ -231,6 +232,10 @@ static void monitor_item_updated_cb (TrackerMonitor
GFile *file,
gboolean is_directory,
gpointer user_data);
+static void monitor_item_attribute_updated_cb (TrackerMonitor *monitor,
+ GFile *file,
+ gboolean is_directory,
+ gpointer user_data);
static void monitor_item_deleted_cb (TrackerMonitor *monitor,
GFile *file,
gboolean is_directory,
@@ -551,6 +556,9 @@ tracker_miner_fs_init (TrackerMinerFS *object)
g_signal_connect (priv->monitor, "item-updated",
G_CALLBACK (monitor_item_updated_cb),
object);
+ g_signal_connect (priv->monitor, "item-attribute-updated",
+ G_CALLBACK (monitor_item_attribute_updated_cb),
+ object);
g_signal_connect (priv->monitor, "item-deleted",
G_CALLBACK (monitor_item_deleted_cb),
object);
@@ -559,6 +567,7 @@ tracker_miner_fs_init (TrackerMinerFS *object)
object);
priv->quark_ignore_file = g_quark_from_static_string ("tracker-ignore-file");
+ priv->quark_attribute_updated = g_quark_from_static_string ("tracker-attribute-updated");
priv->iri_cache = g_hash_table_new_full (g_file_hash,
(GEqualFunc) g_file_equal,
@@ -2834,6 +2843,41 @@ monitor_item_updated_cb (TrackerMonitor *monitor,
}
static void
+monitor_item_attribute_updated_cb (TrackerMonitor *monitor,
+ GFile *file,
+ gboolean is_directory,
+ gpointer user_data)
+{
+ TrackerMinerFS *fs;
+ gboolean should_process;
+ gchar *uri;
+
+ fs = user_data;
+ should_process = should_check_file (fs, file, is_directory);
+
+ uri = g_file_get_uri (file);
+
+ g_debug ("%s:'%s' (%s) (attribute update monitor event or user request)",
+ should_process ? "Found " : "Ignored",
+ uri,
+ is_directory ? "DIR" : "FILE");
+
+ if (should_process) {
+ /* Set the Quark specifying that ONLY attributes were
+ * modified */
+ g_object_set_qdata (G_OBJECT (file),
+ fs->private->quark_attribute_updated,
+ GINT_TO_POINTER (TRUE));
+ g_queue_push_tail (fs->private->items_updated,
+ g_object_ref (file));
+
+ item_queue_handlers_set_up (fs);
+ }
+
+ g_free (uri);
+}
+
+static void
monitor_item_deleted_cb (TrackerMonitor *monitor,
GFile *file,
gboolean is_directory,
diff --git a/src/libtracker-miner/tracker-monitor.c b/src/libtracker-miner/tracker-monitor.c
index bb44fdc..08442f1 100644
--- a/src/libtracker-miner/tracker-monitor.c
+++ b/src/libtracker-miner/tracker-monitor.c
@@ -81,6 +81,7 @@ typedef struct {
enum {
ITEM_CREATED,
ITEM_UPDATED,
+ ITEM_ATTRIBUTE_UPDATED,
ITEM_DELETED,
ITEM_MOVED,
LAST_SIGNAL
@@ -147,6 +148,17 @@ tracker_monitor_class_init (TrackerMonitorClass *klass)
2,
G_TYPE_OBJECT,
G_TYPE_BOOLEAN);
+ signals[ITEM_ATTRIBUTE_UPDATED] =
+ g_signal_new ("item-attribute-updated",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ 0,
+ NULL, NULL,
+ tracker_marshal_VOID__OBJECT_BOOLEAN,
+ G_TYPE_NONE,
+ 2,
+ G_TYPE_OBJECT,
+ G_TYPE_BOOLEAN);
signals[ITEM_DELETED] =
g_signal_new ("item-deleted",
G_TYPE_FROM_CLASS (klass),
@@ -613,7 +625,6 @@ emit_signal_for_event (TrackerMonitor *monitor,
case G_FILE_MONITOR_EVENT_CHANGED:
case G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT:
- case G_FILE_MONITOR_EVENT_ATTRIBUTE_CHANGED:
g_debug ("Emitting ITEM_UPDATED for (%s) '%s'",
event_data->is_directory ? "DIRECTORY" : "FILE",
event_data->file_uri);
@@ -623,6 +634,16 @@ emit_signal_for_event (TrackerMonitor *monitor,
event_data->is_directory);
break;
+ case G_FILE_MONITOR_EVENT_ATTRIBUTE_CHANGED:
+ g_debug ("Emitting ITEM_ATTRIBUTE_UPDATED for (%s) '%s'",
+ 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);
+ break;
+
case G_FILE_MONITOR_EVENT_DELETED:
g_debug ("Emitting ITEM_DELETED for (%s) '%s'",
event_data->is_directory ? "DIRECTORY" : "FILE",
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]