summaryrefslogtreecommitdiff
path: root/libzeitgeist
diff options
context:
space:
mode:
authorSeif Lotfy <seif@lotfy.com>2013-03-04 22:08:30 +0100
committerSeif Lotfy <seif@lotfy.com>2013-03-05 14:09:43 +0100
commit6b62b330e140385534f0d02e90fbb38acc681e33 (patch)
tree8837196140863d3d85993b92a950096b7984e65c /libzeitgeist
parent28d076e74b024b7af9bfc58788ae99b2d52107fc (diff)
downloadzeitgeist-6b62b330e140385534f0d02e90fbb38acc681e33.tar.gz
Add env_variable ZEITGEIST_LOG_DIRECT_READ to control the Log's permission to
read directly from the database.
Diffstat (limited to 'libzeitgeist')
-rw-r--r--libzeitgeist/log.vala7
-rw-r--r--libzeitgeist/utils.vala11
2 files changed, 17 insertions, 1 deletions
diff --git a/libzeitgeist/log.vala b/libzeitgeist/log.vala
index 34ae191d..04f0e577 100644
--- a/libzeitgeist/log.vala
+++ b/libzeitgeist/log.vala
@@ -1,6 +1,8 @@
/*
* Copyright © 2012 Canonical Ltd.
* By Siegfried-A. Gevatter <siegfried.gevatter@collabora.co.uk>
+ * Copyright © 2013 Seif Lotfy <seif@lotfy.com>
+ * Copyright © 2013 Rico Tzschichholz <ricotz@ubuntu.com>
*
* Based upon a C implementation (© 2010-2012 Canonical Ltd) by:
* Mikkel Kamstrup Erlandsen <mikkel.kamstrup@canonical.com>
@@ -81,11 +83,13 @@ public class Log : QueuedProxyWrapper
private HashTable<Monitor, uint> monitors;
private DbReader dbreader;
private ThreadPool<DbWorker> threads;
+ private bool allow_direct_read;
public Log ()
{
monitors = new HashTable<Monitor, uint> (direct_hash, direct_equal);
MainLoop mainloop = new MainLoop();
+ allow_direct_read = Utils.log_may_read_directly ();
Bus.get_proxy.begin<RemoteLog> (BusType.SESSION, Utils.ENGINE_DBUS_NAME,
Utils.ENGINE_DBUS_PATH, 0, null, (obj, res) =>
@@ -143,7 +147,8 @@ public class Log : QueuedProxyWrapper
threads = null;
}
- if (threads != null && proxy.datapath != ":memory:" &&
+ if (allow_direct_read && threads != null &&
+ proxy.datapath != ":memory:" &&
FileUtils.test (proxy.datapath, GLib.FileTest.EXISTS)) {
Utils.set_database_file_path (proxy.datapath);
try {
diff --git a/libzeitgeist/utils.vala b/libzeitgeist/utils.vala
index d3ace4bf..69a8e493 100644
--- a/libzeitgeist/utils.vala
+++ b/libzeitgeist/utils.vala
@@ -5,6 +5,7 @@
* By Siegfried-Angel Gevatter Pujals <siegfried@gevatter.com>
* Copyright © 2011 Michal Hruby <michal.mhr@gmail.com>
* Copyright © 2011 Manish Sinha <manishsinha@ubuntu.com>
+ * Copyright © 2013 Seif Lotfy <seif@lotfy.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
@@ -210,6 +211,16 @@ namespace Zeitgeist
throw new DataModelError.INVALID_SIGNATURE (error_message);
}
+ /**
+ * @return True if direct reading of the DB is enabled for Log, default is True.
+ */
+ public bool log_may_read_directly ()
+ {
+ var env_var = Environment.get_variable ("ZEITGEIST_LOG_DIRECT_READ");
+ if (env_var == null)
+ return true;
+ return (int.parse (env_var) != 0);
+ }
}
}