[tracker-miners/wip/carlosg/stable-content-urns: 8/8] tracker-extract: Use the new stable identifiers in tracker-extract-3




commit 772c9f2ba2e44146eb3793428f765c662cff1f99
Author: Carlos Garnacho <carlosg gnome org>
Date:   Thu Dec 23 20:42:22 2021 +0100

    tracker-extract: Use the new stable identifiers in tracker-extract-3
    
    Port all modules to use this new stable identifier on all TrackerResources
    that express the nie:InformationElement of the file content(s).

 src/tracker-extract/tracker-extract-abw.c          |  5 ++++-
 src/tracker-extract/tracker-extract-bmp.c          |  6 ++++--
 src/tracker-extract/tracker-extract-desktop.c      |  8 +++++++-
 src/tracker-extract/tracker-extract-disc-generic.c |  6 ++++--
 src/tracker-extract/tracker-extract-epub.c         | 10 ++++++++--
 src/tracker-extract/tracker-extract-gif.c          |  6 ++++--
 src/tracker-extract/tracker-extract-gstreamer.c    | 23 ++++++++++++++++++----
 src/tracker-extract/tracker-extract-html.c         |  7 +++++--
 src/tracker-extract/tracker-extract-icon.c         |  6 ++++--
 src/tracker-extract/tracker-extract-iso.c          |  7 +++++--
 src/tracker-extract/tracker-extract-jpeg.c         |  6 ++++--
 src/tracker-extract/tracker-extract-libav.c        |  6 ++++--
 src/tracker-extract/tracker-extract-mp3.c          |  6 ++++--
 src/tracker-extract/tracker-extract-msoffice-xml.c |  7 +++++--
 src/tracker-extract/tracker-extract-msoffice.c     |  6 ++++--
 src/tracker-extract/tracker-extract-oasis.c        |  9 ++++++---
 src/tracker-extract/tracker-extract-pdf.c          | 10 +++++++---
 src/tracker-extract/tracker-extract-playlist.c     |  7 +++++--
 src/tracker-extract/tracker-extract-png.c          |  6 ++++--
 src/tracker-extract/tracker-extract-ps.c           | 13 +++++++-----
 src/tracker-extract/tracker-extract-raw.c          |  6 ++++--
 src/tracker-extract/tracker-extract-text.c         |  6 ++++--
 src/tracker-extract/tracker-extract-tiff.c         |  6 ++++--
 src/tracker-extract/tracker-extract-xps.c          |  7 +++++--
 24 files changed, 132 insertions(+), 53 deletions(-)
---
diff --git a/src/tracker-extract/tracker-extract-abw.c b/src/tracker-extract/tracker-extract-abw.c
index 035c34e14..5f94700c4 100644
--- a/src/tracker-extract/tracker-extract-abw.c
+++ b/src/tracker-extract/tracker-extract-abw.c
@@ -240,9 +240,12 @@ tracker_extract_get_metadata (TrackerExtractInfo  *info,
                GError *error = NULL;
                GMarkupParseContext *context;
                AbwParserData data = { 0 };
+               gchar *resource_uri;
 
                data.uri = g_file_get_uri (f);
-               data.resource = tracker_resource_new (NULL);
+               resource_uri = tracker_file_get_content_identifier (f, NULL, NULL);
+               data.resource = tracker_resource_new (resource_uri);
+               g_free (resource_uri);
 
                tracker_resource_add_uri (data.resource, "rdf:type", "nfo:Document");
 
diff --git a/src/tracker-extract/tracker-extract-bmp.c b/src/tracker-extract/tracker-extract-bmp.c
index 97362d963..e3eed8937 100644
--- a/src/tracker-extract/tracker-extract-bmp.c
+++ b/src/tracker-extract/tracker-extract-bmp.c
@@ -108,7 +108,7 @@ tracker_extract_get_metadata (TrackerExtractInfo  *info,
 {
        TrackerResource *image;
        goffset size;
-       gchar *filename;
+       gchar *filename, *resource_uri;
        GFile *file;
        gint64 width = 0, height = 0;
 
@@ -126,9 +126,11 @@ tracker_extract_get_metadata (TrackerExtractInfo  *info,
                return FALSE;
        }
 
-       image = tracker_resource_new (NULL);
+       resource_uri = tracker_file_get_content_identifier (file, NULL, NULL);
+       image = tracker_resource_new (resource_uri);
        tracker_resource_add_uri (image, "rdf:type", "nfo:Image");
        tracker_resource_add_uri (image, "rdf:type", "nmm:Photo");
+       g_free (resource_uri);
 
        if (get_img_resolution (file, &width, &height)) {
                if (width > 0) {
diff --git a/src/tracker-extract/tracker-extract-desktop.c b/src/tracker-extract/tracker-extract-desktop.c
index c58924649..efc43c986 100644
--- a/src/tracker-extract/tracker-extract-desktop.c
+++ b/src/tracker-extract/tracker-extract-desktop.c
@@ -297,8 +297,14 @@ tracker_extract_get_metadata (TrackerExtractInfo  *info,
                               GError             **error)
 {
        TrackerResource *metadata;
+       gchar *resource_uri;
+       GFile *file;
 
-       metadata = tracker_resource_new (NULL);
+       file = tracker_extract_info_get_file (info);
+
+       resource_uri = tracker_file_get_content_identifier (file, NULL, NULL);
+       metadata = tracker_resource_new (resource_uri);
+       g_free (resource_uri);
 
        if (!process_desktop_file (metadata, tracker_extract_info_get_file (info), error)) {
                g_object_unref (metadata);
diff --git a/src/tracker-extract/tracker-extract-disc-generic.c 
b/src/tracker-extract/tracker-extract-disc-generic.c
index ecf0f0b09..47fedcf88 100644
--- a/src/tracker-extract/tracker-extract-disc-generic.c
+++ b/src/tracker-extract/tracker-extract-disc-generic.c
@@ -104,11 +104,13 @@ build_basic_resource (GFile *cue,
                       GFile *image)
 {
        TrackerResource *metadata, *child;
-       gchar *uri;
+       gchar *uri, *resource_uri;
 
-       metadata = tracker_resource_new (NULL);
+       resource_uri = tracker_file_get_content_identifier (cue, NULL, NULL);
+       metadata = tracker_resource_new (resource_uri);
        tracker_resource_add_uri (metadata, "rdf:type", "nfo:GameImage");
        tracker_resource_set_string (metadata, "nie:mimeType", "application/x-cue");
+       g_free (resource_uri);
 
        uri = g_file_get_uri (cue);
        tracker_resource_add_uri (metadata, "nie:isStoredAs", uri);
diff --git a/src/tracker-extract/tracker-extract-epub.c b/src/tracker-extract/tracker-extract-epub.c
index a6bcdcba6..10428fe6b 100644
--- a/src/tracker-extract/tracker-extract-epub.c
+++ b/src/tracker-extract/tracker-extract-epub.c
@@ -19,6 +19,7 @@
  */
 
 #include <libtracker-extract/tracker-extract.h>
+#include <libtracker-miners-common/tracker-file-utils.h>
 
 #include "tracker-main.h"
 #include "tracker-gsf.h"
@@ -618,7 +619,8 @@ extract_opf (const gchar          *uri,
        GMarkupParseContext *context;
        OPFData *data = NULL;
        GError *error = NULL;
-       gchar *dirname, *contents;
+       gchar *dirname, *contents, *resource_uri;
+       GFile *file;
        GMarkupParser opf_parser = {
                opf_xml_start_element_handler,
                opf_xml_end_element_handler,
@@ -628,8 +630,12 @@ extract_opf (const gchar          *uri,
 
        g_debug ("Extracting OPF file contents from EPUB '%s'", uri);
 
-       ebook = tracker_resource_new (NULL);
+       file = g_file_new_for_uri (uri);
+       resource_uri = tracker_file_get_content_identifier (file, NULL, NULL);
+       ebook = tracker_resource_new (resource_uri);
        tracker_resource_add_uri (ebook, "rdf:type", "nfo:EBook");
+       g_free (resource_uri);
+       g_object_unref (file);
 
        data = opf_data_new (uri, ebook);
 
diff --git a/src/tracker-extract/tracker-extract-gif.c b/src/tracker-extract/tracker-extract-gif.c
index 579693881..f9559efaa 100644
--- a/src/tracker-extract/tracker-extract-gif.c
+++ b/src/tracker-extract/tracker-extract-gif.c
@@ -119,7 +119,7 @@ read_metadata (GifFileType          *gifFile,
        MergeData md = { 0 };
        GifData   gd = { 0 };
        TrackerXmpData *xd = NULL;
-       gchar *sidecar = NULL;
+       gchar *sidecar = NULL, *resource_uri;
 
        do {
                GifByteType *ExtData;
@@ -253,9 +253,11 @@ read_metadata (GifFileType          *gifFile,
        md.date = tracker_coalesce_strip (2, xd->date, xd->time_original);
        md.artist = tracker_coalesce_strip (2, xd->artist, xd->contributor);
 
-       metadata = tracker_resource_new (NULL);
+       resource_uri = tracker_file_get_content_identifier (file, NULL, NULL);
+       metadata = tracker_resource_new (resource_uri);
        tracker_resource_add_uri (metadata, "rdf:type", "nfo:Image");
        tracker_resource_add_uri (metadata, "rdf:type", "nmm:Photo");
+       g_free (resource_uri);
 
        if (sidecar) {
                TrackerResource *sidecar_resource;
diff --git a/src/tracker-extract/tracker-extract-gstreamer.c b/src/tracker-extract/tracker-extract-gstreamer.c
index 14193bb7a..f5bd24d3e 100644
--- a/src/tracker-extract/tracker-extract-gstreamer.c
+++ b/src/tracker-extract/tracker-extract-gstreamer.c
@@ -849,10 +849,15 @@ extract_metadata (MetadataExtractor      *extractor,
                   const gchar            *file_url)
 {
        TrackerResource *resource;
+       gchar *resource_uri;
+       GFile *file;
 
        g_return_val_if_fail (extractor != NULL, NULL);
 
-       resource = tracker_resource_new (NULL);
+       file = g_file_new_for_uri (file_url);
+       resource_uri = tracker_file_get_content_identifier (file, NULL, "1");
+       resource = tracker_resource_new (resource_uri);
+       g_free (resource_uri);
 
        if (extractor->toc) {
                gst_tag_list_insert (extractor->tagcache,
@@ -974,10 +979,18 @@ extract_metadata (MetadataExtractor      *extractor,
                                        /* Reuse the "root" InformationElement resource for the first track,
                                         * so there's no spare ones.
                                         */
-                                       if (node == extractor->toc->entry_list)
+                                       if (node == extractor->toc->entry_list) {
                                                track = resource;
-                                       else
-                                               track = tracker_resource_new (NULL);
+                                       } else {
+                                               gchar *suffix, *resource_uri;
+
+                                               suffix = g_strdup_printf ("%d", g_list_position 
(extractor->toc->entry_list,
+                                                                                                node) + 1);
+                                               resource_uri = tracker_file_get_content_identifier (file, 
NULL, suffix);
+                                               track = tracker_resource_new (resource_uri);
+                                               g_free (resource_uri);
+                                               g_free (suffix);
+                                       }
 
                                        extract_track (track, extractor, node->data, file_url, album_disc);
                                        tracker_resource_set_relation (track, "nie:isStoredAs", 
file_resource);
@@ -1034,6 +1047,8 @@ extract_metadata (MetadataExtractor      *extractor,
 
        common_extract_stream_metadata (extractor, file_url, resource);
 
+       g_object_unref (file);
+
        return resource;
 }
 
diff --git a/src/tracker-extract/tracker-extract-html.c b/src/tracker-extract/tracker-extract-html.c
index 76e31befc..4ce1e1583 100644
--- a/src/tracker-extract/tracker-extract-html.c
+++ b/src/tracker-extract/tracker-extract-html.c
@@ -25,6 +25,7 @@
 #include <glib.h>
 
 #include <libxml/HTMLparser.h>
+#include <libtracker-miners-common/tracker-file-utils.h>
 #include <libtracker-miners-common/tracker-utils.h>
 #include <libtracker-extract/tracker-extract.h>
 
@@ -237,7 +238,7 @@ tracker_extract_get_metadata (TrackerExtractInfo  *info,
        TrackerConfig *config;
        htmlDocPtr doc;
        parser_data pd;
-       gchar *filename;
+       gchar *filename, *resource_uri;
        xmlSAXHandler handler = {
                NULL, /* internalSubset */
                NULL, /* isStandalone */
@@ -275,8 +276,10 @@ tracker_extract_get_metadata (TrackerExtractInfo  *info,
 
        file = tracker_extract_info_get_file (info);
 
-       metadata = tracker_resource_new (NULL);
+       resource_uri = tracker_file_get_content_identifier (file, NULL, NULL);
+       metadata = tracker_resource_new (resource_uri);
        tracker_resource_add_uri (metadata, "rdf:type", "nfo:HtmlDocument");
+       g_free (resource_uri);
 
        pd.metadata = metadata;
        pd.current = -1;
diff --git a/src/tracker-extract/tracker-extract-icon.c b/src/tracker-extract/tracker-extract-icon.c
index d73ad7d4e..90aca1fbf 100644
--- a/src/tracker-extract/tracker-extract-icon.c
+++ b/src/tracker-extract/tracker-extract-icon.c
@@ -133,12 +133,14 @@ tracker_extract_get_metadata (TrackerExtractInfo  *info,
        guint max_width;
        guint max_height;
        GFile *file;
-       gchar *uri;
+       gchar *uri, *resource_uri;
 
        file = tracker_extract_info_get_file (info);
        uri = g_file_get_uri (file);
 
-       metadata = tracker_resource_new (NULL);
+       resource_uri = tracker_file_get_content_identifier (file, NULL, NULL);
+       metadata = tracker_resource_new (resource_uri);
+       g_free (resource_uri);
 
        /* The Windows Icon file format may contain the same icon with different
         * sizes inside, so there's no clear way of setting single width and
diff --git a/src/tracker-extract/tracker-extract-iso.c b/src/tracker-extract/tracker-extract-iso.c
index c4c70900b..2b23dc2df 100644
--- a/src/tracker-extract/tracker-extract-iso.c
+++ b/src/tracker-extract/tracker-extract-iso.c
@@ -29,6 +29,7 @@
 #include <gio/gio.h>
 
 #include <libtracker-extract/tracker-extract.h>
+#include <libtracker-miners-common/tracker-file-utils.h>
 #include <libtracker-sparql/tracker-sparql.h>
 
 G_MODULE_EXPORT gboolean
@@ -43,7 +44,7 @@ tracker_extract_get_metadata (TrackerExtractInfo  *info_,
        /* File information */
        GFile *file;
        GError *inner_error = NULL;
-       gchar *filename;
+       gchar *filename, *resource_uri;
        OsinfoLoader *loader = NULL;
        OsinfoMedia *media;
        OsinfoDb *db;
@@ -60,7 +61,9 @@ tracker_extract_get_metadata (TrackerExtractInfo  *info_,
        file = tracker_extract_info_get_file (info_);
        filename = g_file_get_path (file);
 
-       metadata = tracker_resource_new (NULL);
+       resource_uri = tracker_file_get_content_identifier (file, NULL, NULL);
+       metadata = tracker_resource_new (resource_uri);
+       g_free (resource_uri);
 
        media = osinfo_media_create_from_location (filename, NULL, &inner_error);
        if (inner_error != NULL) {
diff --git a/src/tracker-extract/tracker-extract-jpeg.c b/src/tracker-extract/tracker-extract-jpeg.c
index b5ccc2ef3..b8f4fd267 100644
--- a/src/tracker-extract/tracker-extract-jpeg.c
+++ b/src/tracker-extract/tracker-extract-jpeg.c
@@ -150,7 +150,7 @@ tracker_extract_get_metadata (TrackerExtractInfo  *info,
        GFile *file;
        FILE *f;
        goffset size;
-       gchar *filename, *uri;
+       gchar *filename, *uri, *resource_uri;
        gchar *comment = NULL;
        const gchar *dlna_profile, *dlna_mimetype;
        GPtrArray *keywords;
@@ -183,9 +183,11 @@ tracker_extract_get_metadata (TrackerExtractInfo  *info,
                goto fail;
        }
 
-       metadata = tracker_resource_new (NULL);
+       resource_uri = tracker_file_get_content_identifier (file, NULL, NULL);
+       metadata = tracker_resource_new (resource_uri);
        tracker_resource_add_uri (metadata, "rdf:type", "nfo:Image");
        tracker_resource_add_uri (metadata, "rdf:type", "nmm:Photo");
+       g_free (resource_uri);
 
        jpeg_create_decompress (&cinfo);
 
diff --git a/src/tracker-extract/tracker-extract-libav.c b/src/tracker-extract/tracker-extract-libav.c
index f3eb9e393..b6bc4cfc3 100644
--- a/src/tracker-extract/tracker-extract-libav.c
+++ b/src/tracker-extract/tracker-extract-libav.c
@@ -48,7 +48,7 @@ tracker_extract_get_metadata (TrackerExtractInfo  *info,
        TrackerResource *metadata;
        gchar *absolute_file_path;
        gchar *content_created = NULL;
-       gchar *uri;
+       gchar *uri, *resource_uri;
        AVFormatContext *format = NULL;
        AVStream *audio_stream = NULL;
        AVStream *video_stream = NULL;
@@ -89,7 +89,9 @@ tracker_extract_get_metadata (TrackerExtractInfo  *info,
                return FALSE;
        }
 
-       metadata = tracker_resource_new (NULL);
+       resource_uri = tracker_file_get_content_identifier (file, NULL, NULL);
+       metadata = tracker_resource_new (resource_uri);
+       g_free (resource_uri);
 
        if (audio_stream) {
                if (audio_stream->codec->sample_rate > 0) {
diff --git a/src/tracker-extract/tracker-extract-mp3.c b/src/tracker-extract/tracker-extract-mp3.c
index 254e5381d..3febb4095 100644
--- a/src/tracker-extract/tracker-extract-mp3.c
+++ b/src/tracker-extract/tracker-extract-mp3.c
@@ -2636,7 +2636,7 @@ G_MODULE_EXPORT gboolean
 tracker_extract_get_metadata (TrackerExtractInfo  *info,
                               GError             **error)
 {
-       gchar *filename, *uri;
+       gchar *filename, *uri, *resource_uri;
        int fd;
        void *buffer;
        void *id3v1_buffer;
@@ -2697,7 +2697,9 @@ tracker_extract_get_metadata (TrackerExtractInfo  *info,
 
        g_free (id3v1_buffer);
 
-       main_resource = tracker_resource_new (NULL);
+       resource_uri = tracker_file_get_content_identifier (file, NULL, NULL);
+       main_resource = tracker_resource_new (resource_uri);
+       g_free (resource_uri);
 
        /* Get other embedded tags */
        uri = g_file_get_uri (file);
diff --git a/src/tracker-extract/tracker-extract-msoffice-xml.c 
b/src/tracker-extract/tracker-extract-msoffice-xml.c
index 31d8a7880..81f909ab6 100644
--- a/src/tracker-extract/tracker-extract-msoffice-xml.c
+++ b/src/tracker-extract/tracker-extract-msoffice-xml.c
@@ -24,6 +24,7 @@
 #include <glib.h>
 
 #include <libtracker-extract/tracker-extract.h>
+#include <libtracker-miners-common/tracker-file-utils.h>
 
 #include "tracker-main.h"
 #include "tracker-gsf.h"
@@ -810,7 +811,7 @@ tracker_extract_get_metadata (TrackerExtractInfo  *extract_info,
        GMarkupParseContext *context = NULL;
        GError *inner_error = NULL;
        GFile *file;
-       gchar *uri;
+       gchar *uri, *resource_uri;
 
        if (G_UNLIKELY (maximum_size_error_quark == 0)) {
                maximum_size_error_quark = g_quark_from_static_string ("maximum_size_error");
@@ -827,8 +828,10 @@ tracker_extract_get_metadata (TrackerExtractInfo  *extract_info,
 
        g_debug ("Extracting MsOffice XML format...");
 
-       metadata = tracker_resource_new (NULL);
+       resource_uri = tracker_file_get_content_identifier (file, NULL, NULL);
+       metadata = tracker_resource_new (resource_uri);
        tracker_resource_add_uri (metadata, "rdf:type", "nfo:PaginatedTextDocument");
+       g_free (resource_uri);
 
        /* Setup Parser info */
        info.metadata = metadata;
diff --git a/src/tracker-extract/tracker-extract-msoffice.c b/src/tracker-extract/tracker-extract-msoffice.c
index 06220671b..3d0a590aa 100644
--- a/src/tracker-extract/tracker-extract-msoffice.c
+++ b/src/tracker-extract/tracker-extract-msoffice.c
@@ -1621,7 +1621,7 @@ tracker_extract_get_metadata (TrackerExtractInfo  *info,
        TrackerResource *metadata;
        TrackerConfig *config;
        GsfInfile *infile = NULL;
-       gchar *content = NULL, *uri;
+       gchar *content = NULL, *uri, *resource_uri;
        gboolean is_encrypted = FALSE;
        const gchar *mime_used;
        gsize max_bytes;
@@ -1661,9 +1661,11 @@ tracker_extract_get_metadata (TrackerExtractInfo  *info,
                return FALSE;
        }
 
-       metadata = tracker_resource_new (NULL);
+       resource_uri = tracker_file_get_content_identifier (file, NULL, NULL);
+       metadata = tracker_resource_new (resource_uri);
 
        tracker_resource_add_uri (metadata, "rdf:type", "nfo:PaginatedTextDocument");
+       g_free (resource_uri);
 
        /* Extracting summary */
        extract_summary (metadata, infile, uri);
diff --git a/src/tracker-extract/tracker-extract-oasis.c b/src/tracker-extract/tracker-extract-oasis.c
index b29ae5971..63b8c31a0 100644
--- a/src/tracker-extract/tracker-extract-oasis.c
+++ b/src/tracker-extract/tracker-extract-oasis.c
@@ -175,7 +175,7 @@ tracker_extract_get_metadata (TrackerExtractInfo  *extract_info,
        ODTMetadataParseInfo info = { 0 };
        ODTFileType file_type;
        GFile *file;
-       gchar *uri;
+       gchar *uri, *resource_uri;
        const gchar *mime_used;
        GMarkupParseContext *context;
        GMarkupParser parser = {
@@ -190,10 +190,13 @@ tracker_extract_get_metadata (TrackerExtractInfo  *extract_info,
                maximum_size_error_quark = g_quark_from_static_string ("maximum_size_error");
        }
 
-       metadata = tracker_resource_new (NULL);
+       file = tracker_extract_info_get_file (extract_info);
+
+       resource_uri = tracker_file_get_content_identifier (file, NULL, NULL);
+       metadata = tracker_resource_new (resource_uri);
        mime_used = tracker_extract_info_get_mimetype (extract_info);
+       g_free (resource_uri);
 
-       file = tracker_extract_info_get_file (extract_info);
        uri = g_file_get_uri (file);
 
        /* Setup conf */
diff --git a/src/tracker-extract/tracker-extract-pdf.c b/src/tracker-extract/tracker-extract-pdf.c
index 40c0c98e4..eb62ddf95 100644
--- a/src/tracker-extract/tracker-extract-pdf.c
+++ b/src/tracker-extract/tracker-extract-pdf.c
@@ -299,7 +299,7 @@ tracker_extract_get_metadata (TrackerExtractInfo  *info,
        GPtrArray *keywords;
        guint i;
        GFile *file;
-       gchar *filename;
+       gchar *filename, *resource_uri;
        int fd;
        gchar *contents = NULL;
        gsize len;
@@ -350,7 +350,9 @@ tracker_extract_get_metadata (TrackerExtractInfo  *info,
 
        if (inner_error) {
                if (inner_error->code == POPPLER_ERROR_ENCRYPTED) {
-                       metadata = tracker_resource_new (NULL);
+                       resource_uri = tracker_file_get_content_identifier (file, NULL, NULL);
+                       metadata = tracker_resource_new (resource_uri);
+                       g_free (resource_uri);
 
                        tracker_resource_add_uri (metadata, "rdf:type", "nfo:PaginatedTextDocument");
                        tracker_resource_set_boolean (metadata, "nfo:isContentEncrypted", TRUE);
@@ -381,8 +383,10 @@ tracker_extract_get_metadata (TrackerExtractInfo  *info,
                return FALSE;
        }
 
-       metadata = tracker_resource_new (NULL);
+       resource_uri = tracker_file_get_content_identifier (file, NULL, NULL);
+       metadata = tracker_resource_new (resource_uri);
        tracker_resource_add_uri (metadata, "rdf:type", "nfo:PaginatedTextDocument");
+       g_free (resource_uri);
 
        g_object_get (document,
                      "title", &pd.title,
diff --git a/src/tracker-extract/tracker-extract-playlist.c b/src/tracker-extract/tracker-extract-playlist.c
index c95f85a02..d45c6a498 100644
--- a/src/tracker-extract/tracker-extract-playlist.c
+++ b/src/tracker-extract/tracker-extract-playlist.c
@@ -31,6 +31,7 @@
 
 #include <libtracker-extract/tracker-extract.h>
 #include <libtracker-extract/tracker-guarantee.h>
+#include <libtracker-miners-common/tracker-file-utils.h>
 
 #define PLAYLIST_PROPERTY_NO_TRACKS "entryCounter"
 #define PLAYLIST_PROPERTY_DURATION  "listDuration"
@@ -122,13 +123,15 @@ tracker_extract_get_metadata (TrackerExtractInfo  *info,
        TrackerResource *metadata;
        PlaylistMetadata data;
        GFile *file;
-       gchar *uri;
+       gchar *uri, *resource_uri;
 
        pl = totem_pl_parser_new ();
        file = tracker_extract_info_get_file (info);
        uri = g_file_get_uri (file);
 
-       metadata = data.metadata = tracker_resource_new (NULL);
+       resource_uri = tracker_file_get_content_identifier (file, NULL, NULL);
+       metadata = data.metadata = tracker_resource_new (resource_uri);
+       g_free (resource_uri);
 
        data.track_counter = PLAYLIST_DEFAULT_NO_TRACKS;
        data.total_time =  PLAYLIST_DEFAULT_DURATION;
diff --git a/src/tracker-extract/tracker-extract-png.c b/src/tracker-extract/tracker-extract-png.c
index bf5991cbd..b58425ab3 100644
--- a/src/tracker-extract/tracker-extract-png.c
+++ b/src/tracker-extract/tracker-extract-png.c
@@ -652,7 +652,7 @@ tracker_extract_get_metadata (TrackerExtractInfo  *info,
        gint bit_depth, color_type;
        gint interlace_type, compression_type, filter_type;
        const gchar *dlna_profile, *dlna_mimetype;
-       gchar *filename, *uri;
+       gchar *filename, *uri, *resource_uri;
        GFile *file;
 
        file = tracker_extract_info_get_file (info);
@@ -730,7 +730,9 @@ tracker_extract_get_metadata (TrackerExtractInfo  *info,
 
        png_read_end (png_ptr, end_ptr);
 
-       metadata = tracker_resource_new (NULL);
+       resource_uri = tracker_file_get_content_identifier (file, NULL, NULL);
+       metadata = tracker_resource_new (resource_uri);
+       g_free (resource_uri);
 
        tracker_resource_add_uri (metadata, "rdf:type", "nfo:Image");
        tracker_resource_add_uri (metadata, "rdf:type", "nmm:Photo");
diff --git a/src/tracker-extract/tracker-extract-ps.c b/src/tracker-extract/tracker-extract-ps.c
index a78a3f200..47d501320 100644
--- a/src/tracker-extract/tracker-extract-ps.c
+++ b/src/tracker-extract/tracker-extract-ps.c
@@ -95,18 +95,21 @@ date_to_iso8601 (const gchar *date)
 }
 
 static TrackerResource *
-extract_ps_from_inputstream (GInputStream *stream)
+extract_ps_from_inputstream (GInputStream *stream,
+                             GFile        *file)
 {
        TrackerResource *metadata;
        g_autoptr(GDataInputStream) data_stream = NULL;
-       gchar *line;
+       gchar *line, *resource_uri;
        gsize length, accum, max_bytes;
        gboolean pageno_atend = FALSE;
        gboolean header_finished = FALSE;
        g_autoptr(GError) error = NULL;
 
-       metadata = tracker_resource_new (NULL);
+       resource_uri = tracker_file_get_content_identifier (file, NULL, NULL);
+       metadata = tracker_resource_new (resource_uri);
        tracker_resource_add_uri (metadata, "rdf:type", "nfo:PaginatedTextDocument");
+       g_free (resource_uri);
 
        data_stream = g_data_input_stream_new (stream);
 
@@ -177,7 +180,7 @@ extract_ps (const gchar *uri)
                return NULL;
        }
 
-       return extract_ps_from_inputstream (stream);
+       return extract_ps_from_inputstream (stream, file);
 }
 
 #ifdef USING_UNZIPPSFILES
@@ -203,7 +206,7 @@ extract_ps_gz (const gchar *uri)
        converter = G_CONVERTER (g_zlib_decompressor_new (G_ZLIB_COMPRESSOR_FORMAT_GZIP));
        cstream = g_converter_input_stream_new (stream, converter);
 
-       return extract_ps_from_inputstream (cstream);
+       return extract_ps_from_inputstream (cstream, file);
 }
 
 #endif /* USING_UNZIPPSFILES */
diff --git a/src/tracker-extract/tracker-extract-raw.c b/src/tracker-extract/tracker-extract-raw.c
index 7f775ef63..9aad99581 100644
--- a/src/tracker-extract/tracker-extract-raw.c
+++ b/src/tracker-extract/tracker-extract-raw.c
@@ -332,7 +332,7 @@ tracker_extract_get_metadata (TrackerExtractInfo  *info,
        const gchar *time_content_created;
        gchar *filename = NULL;
        gchar *nfo_orientation = NULL;
-       gchar *uri = NULL;
+       gchar *uri = NULL, *resource_uri;
        gint height;
        gint width;
 
@@ -345,9 +345,11 @@ tracker_extract_get_metadata (TrackerExtractInfo  *info,
                goto out;
        }
 
-       resource = tracker_resource_new (NULL);
+       resource_uri = tracker_file_get_content_identifier (file, NULL, NULL);
+       resource = tracker_resource_new (resource_uri);
        tracker_resource_add_uri (resource, "rdf:type", "nfo:Image");
        tracker_resource_add_uri (resource, "rdf:type", "nmm:Photo");
+       g_free (resource_uri);
 
        width = gexiv2_metadata_get_pixel_width (metadata);
        tracker_resource_set_int (resource, "nfo:width", width);
diff --git a/src/tracker-extract/tracker-extract-text.c b/src/tracker-extract/tracker-extract-text.c
index 4d51ec560..df6d1018a 100644
--- a/src/tracker-extract/tracker-extract-text.c
+++ b/src/tracker-extract/tracker-extract-text.c
@@ -102,15 +102,17 @@ tracker_extract_get_metadata (TrackerExtractInfo  *info,
        TrackerConfig *config;
        GFile *file;
        GSList *text_allowlist_patterns;
-       gchar *content = NULL;
+       gchar *content = NULL, *resource_uri;
        GError *inner_error = NULL;
 
        config = tracker_main_get_config ();
        text_allowlist_patterns = tracker_config_get_text_allowlist_patterns (config);
        file = tracker_extract_info_get_file (info);
 
-       metadata = tracker_resource_new (NULL);
+       resource_uri = tracker_file_get_content_identifier (file, NULL, NULL);
+       metadata = tracker_resource_new (resource_uri);
        tracker_resource_add_uri (metadata, "rdf:type", "nfo:PlainTextDocument");
+       g_free (resource_uri);
 
        if (allow_file (text_allowlist_patterns, file)) {
                content = get_file_content (tracker_extract_info_get_file (info),
diff --git a/src/tracker-extract/tracker-extract-tiff.c b/src/tracker-extract/tracker-extract-tiff.c
index 779ca4379..1b67e24dd 100644
--- a/src/tracker-extract/tracker-extract-tiff.c
+++ b/src/tracker-extract/tracker-extract-tiff.c
@@ -261,7 +261,7 @@ tracker_extract_get_metadata (TrackerExtractInfo  *info,
        TrackerExifData *ed = NULL;
        MergeData md = { 0 };
        TiffData td = { 0 };
-       gchar *filename, *uri;
+       gchar *filename, *uri, *resource_uri;
        gchar *date;
        glong exif_offset;
        GPtrArray *keywords;
@@ -304,9 +304,11 @@ tracker_extract_get_metadata (TrackerExtractInfo  *info,
                return FALSE;
        }
 
-       metadata = tracker_resource_new (NULL);
+       resource_uri = tracker_file_get_content_identifier (file, NULL, NULL);
+       metadata = tracker_resource_new (resource_uri);
        tracker_resource_add_uri (metadata, "rdf:type", "nfo:Image");
        tracker_resource_add_uri (metadata, "rdf:type", "nmm:Photo");
+       g_free (resource_uri);
 
        uri = g_file_get_uri (file);
 
diff --git a/src/tracker-extract/tracker-extract-xps.c b/src/tracker-extract/tracker-extract-xps.c
index f59c6e8d8..0b467b690 100644
--- a/src/tracker-extract/tracker-extract-xps.c
+++ b/src/tracker-extract/tracker-extract-xps.c
@@ -23,6 +23,7 @@
 #include <libgxps/gxps.h>
 
 #include <libtracker-extract/tracker-extract.h>
+#include <libtracker-miners-common/tracker-file-utils.h>
 
 G_MODULE_EXPORT gboolean
 tracker_extract_get_metadata (TrackerExtractInfo  *info,
@@ -32,7 +33,7 @@ tracker_extract_get_metadata (TrackerExtractInfo  *info,
        GXPSDocument *document;
        GXPSFile *xps_file;
        GFile *file;
-       gchar *filename;
+       gchar *filename, *resource_uri;
        GError *inner_error = NULL;
 
        file = tracker_extract_info_get_file (info);
@@ -54,9 +55,11 @@ tracker_extract_get_metadata (TrackerExtractInfo  *info,
                return FALSE;
        }
 
-       resource = tracker_resource_new (NULL);
+       resource_uri = tracker_file_get_content_identifier (file, NULL, NULL);
+       resource = tracker_resource_new (resource_uri);
        tracker_resource_add_uri (resource, "rdf:type", "nfo:PaginatedTextDocument");
        tracker_resource_set_int64 (resource, "nfo:pageCount", gxps_document_get_n_pages (document));
+       g_free (resource_uri);
 
        g_object_unref (document);
        g_free (filename);


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