[tracker-miners/wip/carlosg/cue-file-lookups: 2/4] tracker-extract: Get local connection to tracker-miner-fs-3 database




commit ef08b781aa585539255beee636720b22f8873940
Author: Carlos Garnacho <carlosg gnome org>
Date:   Mon Oct 3 11:49:59 2022 +0200

    tracker-extract: Get local connection to tracker-miner-fs-3 database
    
    As the seccomp jail works, extractor modules may have a hard time poking
    at DBus things, so we cannot obtain a dbus connection here. We can however
    open files readonly, so open the database this way.
    
    This will allow to use the miner database to resolve miscellaneous queries
    about files surrounding the file being extracted (e.g. cue sheets).

 src/tracker-extract/tracker-extract-gstreamer.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
---
diff --git a/src/tracker-extract/tracker-extract-gstreamer.c b/src/tracker-extract/tracker-extract-gstreamer.c
index b521962dc..bb2f0e48f 100644
--- a/src/tracker-extract/tracker-extract-gstreamer.c
+++ b/src/tracker-extract/tracker-extract-gstreamer.c
@@ -54,6 +54,7 @@
 #include <libtracker-extract/tracker-extract.h>
 
 #include "tracker-cue-sheet.h"
+#include "tracker-main.h"
 
 typedef enum {
        EXTRACT_MIME_AUDIO,
@@ -104,6 +105,8 @@ typedef struct {
 #endif
 } MetadataExtractor;
 
+static TrackerSparqlConnection *local_conn = NULL;
+
 static void common_extract_stream_metadata (MetadataExtractor    *extractor,
                                             const gchar          *uri,
                                             TrackerResource      *resource);
@@ -1357,6 +1360,9 @@ tracker_extract_gstreamer (const gchar          *uri,
                }
 
                if (extractor->toc == NULL) {
+                       if (!local_conn)
+                               local_conn = tracker_main_get_readonly_connection (NULL);
+
                        extractor->toc = tracker_cue_sheet_guess_from_uri (uri);
                }
 
@@ -1472,3 +1478,10 @@ tracker_extract_module_init (GError **error)
 
        return TRUE;
 }
+
+G_MODULE_EXPORT gboolean
+tracker_extract_module_shutdown (void)
+{
+       g_clear_object (&local_conn);
+       return TRUE;
+}


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