[tracker-miners/sam/extract-validation: 2/3] tracker-extract: Follow Nepomuk correctly in --file output




commit 1fc425db06a7118043998b6a855bfb555cea66f7
Author: Sam Thursfield <sam afuera me uk>
Date:   Fri Oct 9 19:57:06 2020 +0200

    tracker-extract: Follow Nepomuk correctly in --file output
    
    When called with `--file --output-format=sparql`, it now correctly
    separates the FileDataObject and the InformationElement resources.

 src/tracker-extract/tracker-extract.c | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)
---
diff --git a/src/tracker-extract/tracker-extract.c b/src/tracker-extract/tracker-extract.c
index 3406164d3..6270f7e8e 100644
--- a/src/tracker-extract/tracker-extract.c
+++ b/src/tracker-extract/tracker-extract.c
@@ -696,11 +696,21 @@ tracker_extract_get_metadata_by_cmdline (TrackerExtract             *object,
        if (resource) {
                if (output_format == TRACKER_SERIALIZATION_FORMAT_SPARQL) {
                        char *text;
+                       g_autoptr (TrackerResource) file_resource = NULL;
 
-                       /* If this was going into the tracker-store we'd generate a unique ID
-                        * here, so that the data persisted across file renames.
+                       /* Set up the corresponding nfo:FileDataObject resource appropriately,
+                        * so the SPARQL we generate is valid according to Nepomuk.
                         */
-                       tracker_resource_set_identifier (resource, uri);
+                       file_resource = tracker_resource_get_first_relation (resource, "nie:isStoredAs");
+
+                       if (file_resource) {
+                               g_object_ref (file_resource);
+                       } else {
+                               file_resource = tracker_resource_new (uri);
+                               tracker_resource_set_relation (resource, "nie:isStoredAs", file_resource);
+                       }
+
+                       tracker_resource_add_uri (file_resource, "rdf:type", "nfo:FileDataObject");
 
                        text = tracker_resource_print_sparql_update (resource, NULL, NULL);
 


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