[tracker] libtracker-common: Actually ignore XDG dirs set to $HOME



commit 38f7a0f22f42d9701e7faadf646460482bc76208
Author: Carlos Garnacho <carlosg gnome org>
Date:   Sun May 22 00:23:27 2016 +0200

    libtracker-common: Actually ignore XDG dirs set to $HOME
    
    If an XDG dir is set to $HOME, we do ignore it (So it's not inadvertently
    indexed recursively). However we just made the expansion to the real path
    fail, the alias (e.g. &VIDEOS) was still dealt with as a path, and
    attempted to be indexed.
    
    So now we always return TRUE if the alias has a mapping, but only return
    the string if the path is to our liking. This makes the alias truly
    ignored.

 src/libtracker-common/tracker-file-utils.c |   28 +++++++++++++---------------
 1 files changed, 13 insertions(+), 15 deletions(-)
---
diff --git a/src/libtracker-common/tracker-file-utils.c b/src/libtracker-common/tracker-file-utils.c
index a45f4b3..3d480b9 100644
--- a/src/libtracker-common/tracker-file-utils.c
+++ b/src/libtracker-common/tracker-file-utils.c
@@ -518,8 +518,9 @@ const struct {
 };
 
 
-static gchar *
-get_user_special_dir_if_not_home (const gchar *path)
+static gboolean
+get_user_special_dir_if_not_home (const gchar  *path,
+                                  gchar       **special_dir)
 {
        int i;
        const gchar *real_path;
@@ -527,6 +528,7 @@ get_user_special_dir_if_not_home (const gchar *path)
        gboolean res;
 
        real_path = NULL;
+       *special_dir = NULL;
 
        for (i = 0; i < G_N_ELEMENTS(special_dirs); i++) {
                if (strcmp (path, special_dirs[i].symbol) == 0) {
@@ -542,21 +544,20 @@ get_user_special_dir_if_not_home (const gchar *path)
        }
 
        if (real_path == NULL)
-               return NULL;
+               return FALSE;
 
        file = g_file_new_for_path (real_path);
        home = g_file_new_for_path (g_get_home_dir ());
 
-       res = g_file_equal (file, home);
+       /* ignore XDG directories set to $HOME */
+       if (!g_file_equal (file, home)) {
+               *special_dir = g_strdup (real_path);
+       }
+
        g_object_unref (file);
        g_object_unref (home);
 
-       if (res) {
-               /* ignore XDG directories set to $HOME */
-               return NULL;
-       } else {
-               return g_strdup (real_path);
-       }
+       return TRUE;
 }
 
 
@@ -577,13 +578,10 @@ tracker_path_evaluate_name (const gchar *path)
        }
 
        /* See if it is a special directory name. */
-       special_dir_path = get_user_special_dir_if_not_home (path);
-
-       if (special_dir_path != NULL) {
+       if (get_user_special_dir_if_not_home (path, &special_dir_path))
                return special_dir_path;
-       }
 
-       /* First check the simple case of using tilder */
+       /* First check the simple case of using tilde */
        if (path[0] == '~') {
                const gchar *home;
 


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