[tracker-miners/wip/carlosg/moved-files: 3/4] tracker-extract: Delete nfo:FileDataObject on file access errors




commit 4e649edead88b91292867f6bbd5c7fca59147669
Author: Carlos Garnacho <carlosg gnome org>
Date:   Tue Sep 15 14:22:08 2020 +0200

    tracker-extract: Delete nfo:FileDataObject on file access errors
    
    This is a safety net, as usually tracker-miner-fs is responsible for
    managing the nfo:FileDataObject information. Should a bug happen, we
    don't want to have tracker-extract spin on these files, so trim this
    data away.
    
    Fixes: https://gitlab.gnome.org/GNOME/tracker-miners/-/issues/118

 src/tracker-extract/tracker-extract-decorator.c | 43 ++++++++++++++++---------
 1 file changed, 28 insertions(+), 15 deletions(-)
---
diff --git a/src/tracker-extract/tracker-extract-decorator.c b/src/tracker-extract/tracker-extract-decorator.c
index dfdd3e274..bc25ceb72 100644
--- a/src/tracker-extract/tracker-extract-decorator.c
+++ b/src/tracker-extract/tracker-extract-decorator.c
@@ -432,25 +432,38 @@ decorator_ignore_file (GFile    *file,
                                  G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE,
                                  G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
                                  NULL, &error);
-       if (!info) {
-               g_warning ("Could not get mimetype: %s", error->message);
-               g_error_free (error);
-               return;
-       }
 
-       tracker_error_report (file, "Crash/hang handling file", NULL);
+       if (info) {
+               tracker_error_report (file, "Crash/hang handling file", NULL);
 
-       mimetype = g_file_info_get_attribute_string (info,
-                                                    G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE);
-       hash = tracker_extract_module_manager_get_hash (mimetype);
-       g_object_unref (info);
+               mimetype = g_file_info_get_attribute_string (info,
+                                                            G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE);
+               hash = tracker_extract_module_manager_get_hash (mimetype);
+               g_object_unref (info);
 
-       conn = tracker_miner_get_connection (TRACKER_MINER (decorator));
-       query = g_strdup_printf ("INSERT DATA { GRAPH tracker:FileSystem {"
-                                "  <%s> tracker:extractorHash \"%s\" ;"
-                                "}}",
-                                uri, hash);
+               query = g_strdup_printf ("INSERT DATA { GRAPH tracker:FileSystem {"
+                                        "  <%s> tracker:extractorHash \"%s\" ;"
+                                        "}}",
+                                        uri, hash);
+       } else {
+               g_debug ("Could not get mimetype: %s", error->message);
 
+               if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND))
+                       tracker_error_report_delete (file);
+               else
+                       tracker_error_report (file, error->message, NULL);
+
+               g_clear_error (&error);
+               query = g_strdup_printf ("DELETE {"
+                                        "  GRAPH ?g { <%s> a rdfs:Resource }"
+                                        "} WHERE {"
+                                        "  GRAPH ?g { <%s> a nfo:FileDataObject }"
+                                        "  FILTER (?g != tracker:FileSystem)"
+                                        "}",
+                                        uri, uri);
+       }
+
+       conn = tracker_miner_get_connection (TRACKER_MINER (decorator));
        tracker_sparql_connection_update (conn, query, NULL, &error);
 
        if (error) {


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