From 46d7c0edfbf97ca15c08e5cd1c6d563363843e82 Mon Sep 17 00:00:00 2001 From: Sam Thursfield Date: Sun, 29 Sep 2019 16:42:29 +0200 Subject: [PATCH 1/2] tracker: Fix crash if chromaprint plugin isn't installed This is a regression from 7fa5126eace8d9931643f. See: https://gitlab.gnome.org/GNOME/grilo-plugins/issues/61 --- src/tracker/grl-tracker-utils.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/tracker/grl-tracker-utils.c b/src/tracker/grl-tracker-utils.c index 86f0f0c8..406f4efc 100644 --- a/src/tracker/grl-tracker-utils.c +++ b/src/tracker/grl-tracker-utils.c @@ -325,11 +325,13 @@ grl_tracker_setup_key_mappings (void) "(SELECT tracker:referenceIdentifier(?rg) AS ?rg_id { ?urn nmm:musicAlbum ?album . ?album tracker:hasExternalReference ?rg . ?rg tracker:referenceSource \"https://musicbrainz.org/doc/Release_Group\" })", "audio"); - insert_key_mapping_with_setter (grl_metadata_key_chromaprint, - NULL, - "(select nfo:hashValue(?h) { ?urn nfo:hasHash ?h . ?h nfo:hashAlgorithm \"chromaprint\" })", - "audio", - set_string_metadata_keys); + if (grl_metadata_key_chromaprint != 0) { + insert_key_mapping_with_setter (grl_metadata_key_chromaprint, + NULL, + "(select nfo:hashValue(?h) { ?urn nfo:hasHash ?h . ?h nfo:hashAlgorithm \"chromaprint\" })", + "audio", + set_string_metadata_keys); + }; insert_key_mapping (GRL_METADATA_KEY_FRAMERATE, "nfo:frameRate", -- 2.22.0 From 39e51d93175f8234dd3e9ab99209056f188dbc28 Mon Sep 17 00:00:00 2001 From: Sam Thursfield Date: Sun, 29 Sep 2019 18:03:38 +0200 Subject: [PATCH 2/2] tracker: Guard against invalid key mappings Any future mistakes like https://gitlab.gnome.org/GNOME/grilo-plugins/issues/61 will not crash the process but will just trigger a g_warning() message. --- src/tracker/grl-tracker-utils.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/tracker/grl-tracker-utils.c b/src/tracker/grl-tracker-utils.c index 406f4efc..ed7fb324 100644 --- a/src/tracker/grl-tracker-utils.c +++ b/src/tracker/grl-tracker-utils.c @@ -157,10 +157,16 @@ insert_key_mapping (GrlKeyID grl_key, const gchar *sparql_key_attr_call, const gchar *sparql_key_flavor) { - tracker_grl_sparql_t *assoc = g_new0 (tracker_grl_sparql_t, 1); - GList *assoc_list = g_hash_table_lookup (grl_to_sparql_mapping, - GRLKEYID_TO_POINTER (grl_key)); - gchar *canon_name = g_strdup (GRL_METADATA_KEY_GET_NAME (grl_key)); + tracker_grl_sparql_t *assoc; + GList *assoc_list; + gchar *canon_name; + + g_return_val_if_fail (grl_key != GRL_METADATA_KEY_INVALID, NULL); + + assoc = g_new0 (tracker_grl_sparql_t, 1); + assoc_list = g_hash_table_lookup (grl_to_sparql_mapping, + GRLKEYID_TO_POINTER (grl_key)); + canon_name = g_strdup (GRL_METADATA_KEY_GET_NAME (grl_key)); assoc->grl_key = grl_key; assoc->sparql_key_name = build_flavored_key (canon_name, -- 2.22.0