zeitgeist team mailing list archive
-
zeitgeist team
-
Mailing list archive
-
Message #05368
[Branch ~zeitgeist/zeitgeist/bluebird] Rev 458: FTS++: Ubuntu One events blacklist:
------------------------------------------------------------
revno: 458
committer: Siegfried-Angel Gevatter Pujals <siegfried@xxxxxxxxxxxx>
branch nick: bluebird
timestamp: Tue 2012-04-03 20:40:44 +0200
message:
FTS++: Ubuntu One events blacklist:
- Move blacklist check to separate function.
- Exclude blacklisted events from the Zeitgeist query when reindexing.
- Add environment variable to disable blacklisting.
modified:
extensions/fts++/controller.cpp
extensions/fts++/indexer.cpp
extensions/fts++/indexer.h
extensions/fts++/test/test-indexer.cpp
--
lp:zeitgeist
https://code.launchpad.net/~zeitgeist/zeitgeist/bluebird
Your team Zeitgeist Framework Team is subscribed to branch lp:zeitgeist.
To unsubscribe from this branch go to https://code.launchpad.net/~zeitgeist/zeitgeist/bluebird/+edit-subscription
=== modified file 'extensions/fts++/controller.cpp'
--- extensions/fts++/controller.cpp 2012-03-26 15:09:54 +0000
+++ extensions/fts++/controller.cpp 2012-04-03 18:40:44 +0000
@@ -39,9 +39,23 @@
GError *error = NULL;
guint32 *event_ids;
gint event_ids_size;
- GPtrArray *templates = g_ptr_array_new ();
+ GPtrArray *templates = g_ptr_array_new_with_free_func (g_object_unref);
+ ZeitgeistEvent *event;
ZeitgeistTimeRange *time_range = zeitgeist_time_range_new_anytime ();
+ if (g_getenv ("ZEITGEIST_FTS_DISABLE_EVENT_BLACKLIST") == NULL)
+ {
+ // Blacklist Ubuntu One events...
+
+ event = zeitgeist_event_new ();
+ zeitgeist_event_set_actor (event, "!dbus://com.ubuntuone.SyncDaemon.service");
+ g_ptr_array_add (templates, event);
+
+ event = zeitgeist_event_new ();
+ zeitgeist_event_set_actor (event, "!dbus://org.desktopcouch.CouchDB.service");
+ g_ptr_array_add (templates, event);
+ }
+
g_debug ("asking reader for all events");
event_ids = zeitgeist_db_reader_find_event_ids (zg_reader,
time_range,
=== modified file 'extensions/fts++/indexer.cpp'
--- extensions/fts++/indexer.cpp 2012-03-29 18:02:44 +0000
+++ extensions/fts++/indexer.cpp 2012-04-03 18:40:44 +0000
@@ -1301,14 +1301,23 @@
g_assert (digest_size == NULL || *digest_size == HASH_LENGTH);
}
-void Indexer::IndexEvent (ZeitgeistEvent *event)
+static bool
+CheckEventBlacklisted (ZeitgeistEvent *event)
{
// Blacklist Ubuntu One events...
const gchar *actor;
actor = zeitgeist_event_get_actor (event);
- if (strcmp(actor, "dbus://com.ubuntuone.SyncDaemon.service") == 0)
- return;
- if (strcmp(actor, "dbus://org.desktopcouch.CouchDB.service") == 0)
+ if (g_strcmp0(actor, "dbus://com.ubuntuone.SyncDaemon.service") == 0)
+ return true;
+ if (g_strcmp0(actor, "dbus://org.desktopcouch.CouchDB.service") == 0)
+ return true;
+
+ return false;
+}
+
+void Indexer::IndexEvent (ZeitgeistEvent *event)
+{
+ if (blacklisting_enabled and CheckEventBlacklisted (event))
return;
try
=== modified file 'extensions/fts++/indexer.h'
--- extensions/fts++/indexer.h 2012-03-19 21:42:52 +0000
+++ extensions/fts++/indexer.h 2012-04-03 18:40:44 +0000
@@ -48,6 +48,7 @@
{
const gchar *home_dir = g_get_home_dir ();
home_dir_path = home_dir != NULL ? home_dir : "/home";
+ blacklisting_enabled = g_getenv ("ZEITGEIST_FTS_DISABLE_EVENT_BLACKLIST") == NULL;
}
~Indexer ()
@@ -129,6 +130,7 @@
guint clear_failed_id;
std::string home_dir_path;
+ bool blacklisting_enabled;
};
}
=== modified file 'extensions/fts++/test/test-indexer.cpp'
--- extensions/fts++/test/test-indexer.cpp 2012-03-29 18:02:44 +0000
+++ extensions/fts++/test/test-indexer.cpp 2012-04-03 18:40:44 +0000
@@ -270,6 +270,15 @@
return event;
}
+static void
+process_pending (Fixture *fix)
+{
+ while (zeitgeist_indexer_has_pending_tasks (fix->indexer))
+ {
+ zeitgeist_indexer_process_task (fix->indexer);
+ }
+}
+
// Steals the event, ref it if you want to keep it
static guint
index_event (Fixture *fix, ZeitgeistEvent *event)
@@ -295,10 +304,7 @@
zeitgeist_indexer_index_events (fix->indexer, events);
g_ptr_array_unref (events);
- while (zeitgeist_indexer_has_pending_tasks (fix->indexer))
- {
- zeitgeist_indexer_process_task (fix->indexer);
- }
+ process_pending (fix);
// sleep for 1 msec to make sure the next event will have a
// different timestamp
@@ -1078,17 +1084,36 @@
test_index_ignore_ubuntu_one (Fixture *fix, gconstpointer data)
{
guint matches;
+ ZeitgeistEvent *event;
+ GPtrArray *results;
// add test events to DBs
index_event (fix, create_test_event_simple ("ubuntuone:uuid", "failme"));
- ZeitgeistEvent *event = create_test_event_simple ("file:///nice%20uri", "failme");
+ event = create_test_event_simple ("file:///nice%20uri", "failme");
zeitgeist_event_set_actor (event, "dbus://com.ubuntuone.SyncDaemon.service");
index_event (fix, event);
- GPtrArray *results = search_simple (fix, "failme", NULL,
+ results = search_simple (fix, "failme", NULL,
ZEITGEIST_RESULT_TYPE_MOST_RECENT_EVENTS, &matches);
g_assert_cmpuint (results->len, ==, 0);
+
+ // disabling blacklisting
+ g_setenv ("ZEITGEIST_FTS_DISABLE_EVENT_BLACKLIST", "1", true);
+
+ // create a new FTS instance
+ zeitgeist_indexer_free (fix->indexer);
+ GError *error = NULL;
+ fix->indexer = zeitgeist_indexer_new (fix->db, &error);
+ g_assert (error == NULL);
+
+ // wait for it to rebuild the index
+ process_pending (fix);
+
+ results = search_simple (fix, "failme", NULL,
+ ZEITGEIST_RESULT_TYPE_MOST_RECENT_EVENTS, &matches);
+
+ g_assert_cmpuint (results->len, ==, 1); // we still don't want ubuntuone:uuid
}
G_BEGIN_DECLS