diff --git a/src/trackerd/tracker-utils.c b/src/trackerd/tracker-utils.c index e006676..958d35c 100644 --- a/src/trackerd/tracker-utils.c +++ b/src/trackerd/tracker-utils.c @@ -1824,6 +1824,10 @@ get_files (const char *dir, gboolean dir_only, gboolean skip_ignored_files) GSList *file_list; char *dir_in_locale; + int use_stat = 0; + dev_t dir_dev = 0; + struct stat statbuf; + dir_in_locale = g_filename_from_utf8 (dir, -1, NULL, NULL, NULL); if (!dir_in_locale) { @@ -1832,6 +1836,11 @@ get_files (const char *dir, gboolean dir_only, gboolean skip_ignored_files) return NULL; } + if (g_stat (dir_in_locale, &statbuf) == 0) { + use_stat = 1; /* good device-info for this directory */ + dir_dev = statbuf.st_dev; + } + file_list = NULL; if ((dirp = g_dir_open (dir_in_locale, 0, NULL))) { @@ -1861,9 +1870,17 @@ get_files (const char *dir, gboolean dir_only, gboolean skip_ignored_files) g_free (str); if (!tracker_file_is_valid (mystr)) { + g_free (mystr); continue; } + if (use_stat && g_stat (mystr, &statbuf) == 0) { + if (statbuf.st_dev != dir_dev) { + g_free (mystr); + continue; + } + } + if (!dir_only || tracker_is_directory (mystr)) { if (!tracker_file_is_no_watched (mystr)) {