[tracker-miners/wip/carlosg/dummy-files: 2/2] tracker-extract: Handle dummy modules differently




commit 02f3ca973cf44ad635d75ce68cf06beee425b46b
Author: Carlos Garnacho <carlosg gnome org>
Date:   Sun Aug 2 18:27:28 2020 +0200

    tracker-extract: Handle dummy modules differently
    
    Dummy files broke with the nie:DataObject/nie:InformationElement
    split, as tracker-extract just did nothing while tracker-miner-fs
    pre-filled the barebones nie:InformationElement.
    
    We should at least fill in the rdf:types and the extra info to tie
    the nie:InformationElement and nie:DataObject together, so return
    a barebones TrackerResource to have that information successfully
    attached.
    
    Fixes extraction of games, ebooks, and other files using a dummy
    extractor.

 src/tracker-extract/tracker-extract.c | 35 +++++++++++++++--------------------
 1 file changed, 15 insertions(+), 20 deletions(-)
---
diff --git a/src/tracker-extract/tracker-extract.c b/src/tracker-extract/tracker-extract.c
index 9edc6a673..56107f195 100644
--- a/src/tracker-extract/tracker-extract.c
+++ b/src/tracker-extract/tracker-extract.c
@@ -300,13 +300,18 @@ get_file_metadata (TrackerExtractTask  *task,
        /* Now we have sanity checked everything, actually get the
         * data we need from the extractors.
         */
-       if (task->func) {
+       if (task->func && task->module) {
                g_debug ("Using %s...",
-                        task->module ?
-                        g_module_name (task->module) :
-                        "Dummy extraction");
+                        g_module_name (task->module));
 
                task->success = (task->func) (info);
+       } else {
+               TrackerResource *resource;
+
+               /* Dummy extractor */
+               resource = tracker_resource_new (NULL);
+               tracker_extract_info_set_resource (info, resource);
+               task->success = TRUE;
        }
 
        if (!task->success) {
@@ -564,26 +569,16 @@ dispatch_task_cb (TrackerExtractTask *task)
        priv = TRACKER_EXTRACT_GET_PRIVATE (task->extract);
 
        if (!task->mimetype) {
-               error = g_error_new (tracker_extract_error_quark (),
-                                    TRACKER_EXTRACT_ERROR_NO_MIMETYPE,
-                                    "No mimetype for '%s'", task->file);
+               g_task_return_new_error (G_TASK (task->res),
+                                        tracker_extract_error_quark (),
+                                        TRACKER_EXTRACT_ERROR_NO_MIMETYPE,
+                                        "No mimetype for '%s'", task->file);
+               extract_task_free (task);
+               return FALSE;
        } else {
                task->module = tracker_extract_module_manager_get_module (task->mimetype,
                                                                          NULL,
                                                                          &task->func);
-               if (!task->module) {
-                       error = g_error_new (tracker_extract_error_quark (),
-                                            TRACKER_EXTRACT_ERROR_NO_EXTRACTOR,
-                                            "No mimetype extractor handlers for uri:'%s' and mime:'%s'",
-                                            task->file, task->mimetype);
-               }
-       }
-
-       if (error) {
-               g_task_return_error (G_TASK (task->res), error);
-               extract_task_free (task);
-
-               return FALSE;
        }
 
        task->graph = tracker_extract_module_manager_get_graph (task->mimetype);


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