[tracker/tracker-1.10] applications: Ignore broken symlinks



commit 057634bd003a67126ddb1adf1689ae3e0ec0eb1e
Author: Carlos Garnacho <carlosg gnome org>
Date:   Sun Sep 10 17:01:26 2017 +0200

    applications: Ignore broken symlinks
    
    We still do need to query mtime from the symlink itself in order to keep
    filesystem accounting happy, so wait for ENOENT while doing
    g_key_file_load_from_file() in order to figure out we are dealing with
    a broken link (or a no longer existing file, which is also possible). This
    avoids spewing any warnings with those.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=786132

 src/miners/apps/tracker-miner-applications.c |   34 +++++++++++++++----------
 1 files changed, 20 insertions(+), 14 deletions(-)
---
diff --git a/src/miners/apps/tracker-miner-applications.c b/src/miners/apps/tracker-miner-applications.c
index 749d3e4..a2d1f78 100644
--- a/src/miners/apps/tracker-miner-applications.c
+++ b/src/miners/apps/tracker-miner-applications.c
@@ -430,8 +430,7 @@ get_desktop_key_file (GFile   *file,
        key_file = g_key_file_new ();
        *type = NULL;
 
-       if (!g_key_file_load_from_file (key_file, path, G_KEY_FILE_NONE, NULL)) {
-               g_set_error (error, miner_applications_error_quark, 0, "Couldn't load desktop file:'%s'", 
path);
+       if (!g_key_file_load_from_file (key_file, path, G_KEY_FILE_NONE, error)) {
                g_key_file_free (key_file);
                g_free (path);
                return NULL;
@@ -943,6 +942,7 @@ process_file_cb (GObject      *object,
        ProcessApplicationData *data;
        GFileInfo *file_info;
        GError *error = NULL;
+       GFileType file_type;
        GFile *file;
 
        data = user_data;
@@ -956,21 +956,27 @@ process_file_cb (GObject      *object,
                return;
        }
 
-       if (g_file_info_get_file_type (file_info) == G_FILE_TYPE_DIRECTORY) {
+       file_type = g_file_info_get_file_type (file_info);
+
+       if (file_type == G_FILE_TYPE_DIRECTORY) {
                process_directory (data, file_info, &error);
-       } else {
+       } else if (file_type == G_FILE_TYPE_REGULAR ||
+                  file_type == G_FILE_TYPE_SYMBOLIC_LINK) {
                data->key_file = get_desktop_key_file (file, &data->type, &error);
                if (!data->key_file) {
-                       gchar *uri;
-
-                       uri = g_file_get_uri (file);
-                       g_warning ("Couldn't properly parse desktop file '%s': '%s'",
-                                  uri,
-                                  error ? error->message : "unknown error");
-                       g_free (uri);
-                       g_clear_error (&error);
-
-                       error = g_error_new_literal (miner_applications_error_quark, 0, "File is not a key 
file");
+                       /* Ignore broken symlinks */
+                       if (!g_error_matches (error, G_FILE_ERROR, G_FILE_ERROR_NOENT)) {
+                               gchar *uri;
+
+                               uri = g_file_get_uri (file);
+                               g_warning ("Couldn't properly parse desktop file '%s': '%s'",
+                                          uri,
+                                          error ? error->message : "unknown error");
+                               g_free (uri);
+                               g_clear_error (&error);
+
+                               error = g_error_new_literal (miner_applications_error_quark, 0, "File is not 
a key file");
+                       }
                } else if (g_key_file_get_boolean (data->key_file, GROUP_DESKTOP_ENTRY, "Hidden", NULL)) {
                        error = g_error_new_literal (miner_applications_error_quark, 0, "Desktop file is 
'hidden', not gathering metadata for it");
                } else {


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