[tracker] libtracker-direct: Handle initialization failure
- From: Jürg Billeter <juergbi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker] libtracker-direct: Handle initialization failure
- Date: Mon, 16 Aug 2010 15:37:06 +0000 (UTC)
commit 0793ebe1ba4093ca77c59485b36a8a6fb0a06424
Author: Jürg Billeter <j bitron ch>
Date: Wed Jul 21 16:59:12 2010 +0200
libtracker-direct: Handle initialization failure
src/libtracker-direct/tracker-direct.vala | 22 +++++++++++++++-------
1 files changed, 15 insertions(+), 7 deletions(-)
---
diff --git a/src/libtracker-direct/tracker-direct.vala b/src/libtracker-direct/tracker-direct.vala
index d812855..1dbaf46 100644
--- a/src/libtracker-direct/tracker-direct.vala
+++ b/src/libtracker-direct/tracker-direct.vala
@@ -21,16 +21,20 @@ public class Tracker.Direct.Connection : Tracker.Sparql.Connection {
// only single connection is currently supported per process
static bool initialized;
- public Connection ()
+ public Connection () throws Sparql.Error
requires (!initialized) {
+ if (!Data.Manager.init (DBManagerFlags.READONLY, null, null, false, null, null)) {
+ throw new Sparql.Error.INTERNAL ("Unable to initialize database");
+ }
initialized = true;
- Data.Manager.init (DBManagerFlags.READONLY, null, null, false, null, null);
}
~Connection () {
// Clean up connection
- Data.Manager.shutdown ();
- initialized = false;
+ if (initialized) {
+ Data.Manager.shutdown ();
+ initialized = false;
+ }
}
public override Sparql.Cursor query (string sparql, Cancellable? cancellable) throws Sparql.Error {
@@ -52,7 +56,11 @@ public class Tracker.Direct.Connection : Tracker.Sparql.Connection {
}
}
-public Tracker.Sparql.Connection module_init () {
- Tracker.Sparql.Connection plugin = new Tracker.Direct.Connection ();
- return plugin;
+public Tracker.Sparql.Connection? module_init () {
+ try {
+ Tracker.Sparql.Connection plugin = new Tracker.Direct.Connection ();
+ return plugin;
+ } catch (Tracker.Sparql.Error e) {
+ return null;
+ }
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]