[tracker-miners/wip/jfelder/desktop-link-fix] tracker-extract-desktop: Fix Link type extraction



commit bf2f8ef29bae8bcbd48d0aa09904a4826125a71f
Author: Jean Felder <jfelder src gnome org>
Date:   Wed Apr 22 22:18:12 2020 +0200

    tracker-extract-desktop: Fix Link type extraction
    
    This fixes two issues introduced in commit
    f787f74318e40548382cb0977c68322299eb850a:
    * the uri is not correctly escaped
    * a nfo:WebSite cannot have a nie:url property
    
    The first issue is fixed by using tracker_sparql_escape_uri_printf.
    The second issue is adding the nie:DataObject type to the
    website_resource.

 src/tracker-extract/tracker-extract-desktop.c                    | 9 +++------
 .../desktop/link-wikipedia-tracker.expected.json                 | 2 ++
 2 files changed, 5 insertions(+), 6 deletions(-)
---
diff --git a/src/tracker-extract/tracker-extract-desktop.c b/src/tracker-extract/tracker-extract-desktop.c
index 9860989b0..887c01755 100644
--- a/src/tracker-extract/tracker-extract-desktop.c
+++ b/src/tracker-extract/tracker-extract-desktop.c
@@ -169,22 +169,19 @@ process_desktop_file (TrackerResource  *resource,
 
                if (link_url) {
                        TrackerResource *website_resource;
-                       gchar *escaped_link_url;
                        gchar *link_uri;
 
                        g_strstrip (link_url);
-                       escaped_link_url = g_uri_escape_string (link_url,
-                                                               G_URI_RESERVED_CHARS_ALLOWED_IN_PATH,
-                                                               FALSE);
-                       link_uri = g_strdup_printf (LINK_URN_PREFIX "%s", escaped_link_url);
+                       link_uri = tracker_sparql_escape_uri_printf (LINK_URN_PREFIX "%s", link_url);
+
 
                        website_resource = tracker_resource_new (link_uri);
+                       tracker_resource_add_uri (website_resource, "rdf:type", "nie:DataObject");
                        tracker_resource_add_uri (website_resource, "rdf:type", "nfo:Website");
                        tracker_resource_set_string (website_resource, "nie:url", link_url);
                        tracker_resource_set_take_relation (resource, "nie:isStoredAs", website_resource);
 
                        g_free (link_url);
-                       g_free (escaped_link_url);
                        g_free (link_uri);
                } else {
                        /* a Link desktop entry must have an URL */
diff --git a/tests/functional-tests/test-extraction-data/desktop/link-wikipedia-tracker.expected.json 
b/tests/functional-tests/test-extraction-data/desktop/link-wikipedia-tracker.expected.json
index b4d3456b0..929e975a4 100644
--- a/tests/functional-tests/test-extraction-data/desktop/link-wikipedia-tracker.expected.json
+++ b/tests/functional-tests/test-extraction-data/desktop/link-wikipedia-tracker.expected.json
@@ -5,7 +5,9 @@
     "metadata": {
         "nie:title" : "Wikipedia Tracker",
         "nie:isStoredAs": {
+            "@id": "urn:link:https:%2F%2Fen.wikipedia.org%2Fwiki%2FTracker_(search_software)",
             "@type": [
+                "nie:DataObject",
                 "nfo:Website"
             ],
             "nie:url": "https://en.wikipedia.org/wiki/Tracker_(search_software)"


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