aboutsummaryrefslogtreecommitdiffstats
path: root/community/grilo-plugins/67.patch
blob: d7d62313fe5bc6e63af002b7709fce908ea8dfe3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
From 46d7c0edfbf97ca15c08e5cd1c6d563363843e82 Mon Sep 17 00:00:00 2001
From: Sam Thursfield <sam@afuera.me.uk>
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 <sam@afuera.me.uk>
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