[tracker-miners/wip/carlosg/create-from-scratch] tracker-miner-fs: Always delete graph nie:InformationElement on create/update




commit 96143ae59a77180282de8edcc4ee4b05f7c7e48f
Author: Carlos Garnacho <carlosg gnome org>
Date:   Thu May 26 23:18:32 2022 +0200

    tracker-miner-fs: Always delete graph nie:InformationElement on create/update
    
    There are some situations where the file monitors cannot distinguish between
    a file being created where none existed before, or a file newly created
    replacing a previously existing file.
    
    Treat all create/update events the same WRT trimming the previously
    existing nie:InformationElements, in order to ensure these updates that
    pass as creates also result in the file being reindexed by the
    metadata extractor. This only applies to files that would have metadata
    extracted.
    
    While at it, simplify the SPARQL and move the code so that it is not
    scattered across the function.

 src/miners/fs/tracker-miner-files-methods.c | 48 +++++++++++++----------------
 1 file changed, 22 insertions(+), 26 deletions(-)
---
diff --git a/src/miners/fs/tracker-miner-files-methods.c b/src/miners/fs/tracker-miner-files-methods.c
index e94610ad8..e5eccfb08 100644
--- a/src/miners/fs/tracker-miner-files-methods.c
+++ b/src/miners/fs/tracker-miner-files-methods.c
@@ -131,7 +131,6 @@ tracker_miner_files_process_file (TrackerMinerFS      *fs,
        TrackerResource *resource = NULL, *folder_resource = NULL, *graph_file = NULL;
        const gchar *mime_type, *graph;
        const gchar *parent_urn;
-       gchar *delete_properties_sparql = NULL;
        GFile *parent;
        gchar *uri;
        gboolean is_directory;
@@ -154,29 +153,6 @@ tracker_miner_files_process_file (TrackerMinerFS      *fs,
        if (!modified)
                modified = g_date_time_new_from_unix_utc (0);
 
-       if (!create && !is_directory) {
-               /* In case of update: delete all information elements for the given data object
-                * and delete extractorHash, so we ensure the file is extracted again.
-                */
-               delete_properties_sparql =
-                       g_strdup_printf ("DELETE {"
-                                        "  GRAPH ?g {"
-                                        "    <%s> nie:interpretedAs ?ie . "
-                                        "    ?ie a rdfs:Resource . "
-                                        "  }"
-                                        "} WHERE {"
-                                        "  GRAPH ?g {"
-                                        "    <%s> nie:interpretedAs ?ie ."
-                                        "  }"
-                                        "}; "
-                                        "DELETE WHERE {"
-                                        "  GRAPH " DEFAULT_GRAPH " {"
-                                        "    <%s> tracker:extractorHash ?h ."
-                                        "  }"
-                                        "}",
-                                        uri, uri, uri);
-       }
-
        resource = tracker_resource_new (uri);
 
        tracker_resource_add_uri (resource, "rdf:type", "nfo:FileDataObject");
@@ -268,8 +244,29 @@ tracker_miner_files_process_file (TrackerMinerFS      *fs,
                miner_files_add_to_datasource (TRACKER_MINER_FILES (fs), file, graph_file, NULL);
        }
 
-       if (delete_properties_sparql)
+       if (graph && !is_directory) {
+               gchar *delete_properties_sparql = NULL;
+
+               /* In case of update: delete all information elements for the given data object
+                * and delete extractorHash, so we ensure the file is extracted again.
+                */
+               delete_properties_sparql =
+                       g_strdup_printf ("DELETE WHERE {"
+                                        "  GRAPH ?g {"
+                                        "    <%s> nie:interpretedAs ?ie . "
+                                        "    ?ie a rdfs:Resource . "
+                                        "  }"
+                                        "}; "
+                                        "DELETE WHERE {"
+                                        "  GRAPH " DEFAULT_GRAPH " {"
+                                        "    <%s> tracker:extractorHash ?h ."
+                                        "  }"
+                                        "}",
+                                        uri, uri);
+
                tracker_sparql_buffer_push_sparql (buffer, file, delete_properties_sparql);
+               g_free (delete_properties_sparql);
+       }
 
        tracker_sparql_buffer_push (buffer, file, DEFAULT_GRAPH, resource);
 
@@ -282,7 +279,6 @@ tracker_miner_files_process_file (TrackerMinerFS      *fs,
        g_object_unref (resource);
        g_clear_object (&folder_resource);
        g_clear_object (&graph_file);
-       g_free (delete_properties_sparql);
        g_free (uri);
 }
 


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