[tracker] miner-fs: use GFile to check for homedir



commit 5f06c134f4f6da02027c813322e13c220b51cd0a
Author: Cosimo Cecchi <cosimo endlessm com>
Date:   Tue Dec 9 18:06:11 2014 -0800

    miner-fs: use GFile to check for homedir
    
    Instead of a simple path comparison. This will work with relative paths,
    double slashes and similar scenarios, since the path will be
    fully-canonicalized by GIO before comparison.
    The price to pay is recursively indexing the home directory, so we'd
    better be extra careful...
    
    https://bugzilla.gnome.org/show_bug.cgi?id=741317

 src/miners/fs/tracker-config.c |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)
---
diff --git a/src/miners/fs/tracker-config.c b/src/miners/fs/tracker-config.c
index 733caa6..b297dfd 100644
--- a/src/miners/fs/tracker-config.c
+++ b/src/miners/fs/tracker-config.c
@@ -528,10 +528,18 @@ static gchar *
 get_user_special_dir_if_not_home (GUserDirectory directory)
 {
        const gchar *path;
+       GFile *home, *file;
+       gboolean res;
 
        path = g_get_user_special_dir (directory);
+       file = g_file_new_for_path (path);
+       home = g_file_new_for_path (g_get_home_dir ());
 
-       if (g_strcmp0 (path, g_get_home_dir ()) == 0) {
+       res = g_file_equal (file, home);
+       g_object_unref (file);
+       g_object_unref (home);
+
+       if (res) {
                /* ignore XDG directories set to $HOME */
                return NULL;
        } else {


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