[polari/wip/carlosg/tracker: 428/445] lib: Add explicit method to close the tracker sparql connection




commit 32aebdd97688c7052c83a9564495e296ef46432e
Author: Carlos Garnacho <carlosg gnome org>
Date:   Sun Feb 24 22:51:07 2019 +0100

    lib: Add explicit method to close the tracker sparql connection
    
    One of the responsibilities of a local store is properly shutting
    down the connection on exit. Unclean shutdowns are not problematic
    per se, but will trigger additional checks on next startup.

 src/lib/polari-util.c | 15 +++++++++++++++
 src/lib/polari-util.h |  1 +
 src/main.js           |  2 ++
 src/polari-log-tool.c |  2 ++
 4 files changed, 20 insertions(+)
---
diff --git a/src/lib/polari-util.c b/src/lib/polari-util.c
index abf38c96..3f72a500 100644
--- a/src/lib/polari-util.c
+++ b/src/lib/polari-util.c
@@ -171,3 +171,18 @@ polari_util_get_tracker_connection (gboolean readonly,
 
   return connection;
 }
+
+/**
+ * polari_util_close_tracker_connection:
+ *
+ * Returns: (transfer none):
+ */
+void
+polari_util_close_tracker_connection (void)
+{
+  TrackerSparqlConnection *connection = NULL;
+
+  connection = polari_util_get_tracker_connection (TRUE, NULL);
+  if (connection)
+    g_object_unref (connection);
+}
diff --git a/src/lib/polari-util.h b/src/lib/polari-util.h
index 68049210..fa83be2b 100644
--- a/src/lib/polari-util.h
+++ b/src/lib/polari-util.h
@@ -33,3 +33,4 @@ gboolean polari_util_match_identify_message (const char  *message,
 
 TrackerSparqlConnection *polari_util_get_tracker_connection   (gboolean   readonly,
                                                                GError   **error);
+void                     polari_util_close_tracker_connection (void);
diff --git a/src/main.js b/src/main.js
index 43b72e77..b68c95b7 100755
--- a/src/main.js
+++ b/src/main.js
@@ -2,6 +2,7 @@ import GLib from 'gi://GLib';
 
 import * as Config from './config.js';
 import * as Log from './logging.js';
+import Polari from 'gi://Polari';
 import { ngettext } from 'gettext';
 import { programInvocationName, programArgs } from 'system';
 
@@ -39,3 +40,4 @@ let application = new Application();
 if (GLib.getenv('POLARI_PERSIST'))
     application.hold();
 application.run([programInvocationName, ...programArgs]);
+Polari.util_close_tracker_connection ();
diff --git a/src/polari-log-tool.c b/src/polari-log-tool.c
index dfc9a526..ee80cb74 100644
--- a/src/polari-log-tool.c
+++ b/src/polari-log-tool.c
@@ -167,6 +167,8 @@ handle_import (int   argc,
   g_object_unref (importer);
   g_main_loop_unref (loop);
 
+  polari_util_close_tracker_connection ();
+
   return status;
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]