[tracker] Bug #612966 - Non-Recursively Indexed Directories behavior
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker] Bug #612966 - Non-Recursively Indexed Directories behavior
- Date: Thu, 18 Mar 2010 11:20:12 +0000 (UTC)
commit 463aa9a5197807ec04a34d97e5b4e6065e2df7a0
Author: Carlos Garnacho <carlosg gnome org>
Date: Thu Mar 18 12:16:01 2010 +0100
Bug #612966 - Non-Recursively Indexed Directories behavior
Make a diference between strings and directories lists in configuration,
and between recursive and non-recursive directories lists. So when getting
the IndexSingleDirectories option subdirs aren't filtered out.
src/libtracker-common/tracker-file-utils.c | 7 +-
src/libtracker-common/tracker-file-utils.h | 3 +-
src/libtracker-common/tracker-keyfile-object.c | 86 +++++++++++++++++----
src/libtracker-common/tracker-keyfile-object.h | 14 +++-
src/tracker-miner-fs/tracker-config.c | 19 +++--
tests/libtracker-common/tracker-file-utils-test.c | 2 +-
6 files changed, 100 insertions(+), 31 deletions(-)
---
diff --git a/src/libtracker-common/tracker-file-utils.c b/src/libtracker-common/tracker-file-utils.c
index df14335..172c167 100644
--- a/src/libtracker-common/tracker-file-utils.c
+++ b/src/libtracker-common/tracker-file-utils.c
@@ -376,7 +376,8 @@ tracker_path_hash_table_filter_duplicates (GHashTable *roots)
GSList *
tracker_path_list_filter_duplicates (GSList *roots,
- const gchar *basename_exception_prefix)
+ const gchar *basename_exception_prefix,
+ gboolean is_recursive)
{
GSList *l1, *l2;
GSList *new_list;
@@ -431,7 +432,7 @@ tracker_path_list_filter_duplicates (GSList *roots,
}
}
- if (tracker_path_is_in_path (path, in_path)) {
+ if (is_recursive && tracker_path_is_in_path (path, in_path)) {
g_debug ("Removing path:'%s', it is in path:'%s'",
path, in_path);
@@ -443,7 +444,7 @@ tracker_path_list_filter_duplicates (GSList *roots,
continue;
}
- else if (tracker_path_is_in_path (in_path, path)) {
+ else if (is_recursive && tracker_path_is_in_path (in_path, path)) {
g_debug ("Removing path:'%s', it is in path:'%s'",
in_path, path);
diff --git a/src/libtracker-common/tracker-file-utils.h b/src/libtracker-common/tracker-file-utils.h
index bbdd980..be7cccc 100644
--- a/src/libtracker-common/tracker-file-utils.h
+++ b/src/libtracker-common/tracker-file-utils.h
@@ -47,7 +47,8 @@ gboolean tracker_path_is_in_path (const gchar *path,
const gchar *in_path);
void tracker_path_hash_table_filter_duplicates (GHashTable *roots);
GSList * tracker_path_list_filter_duplicates (GSList *roots,
- const gchar *basename_exception_prefix);
+ const gchar *basename_exception_prefix,
+ gboolean is_recursive);
gchar * tracker_path_evaluate_name (const gchar *uri);
gboolean tracker_path_has_write_access_or_was_created (const gchar *path);
diff --git a/src/libtracker-common/tracker-keyfile-object.c b/src/libtracker-common/tracker-keyfile-object.c
index 25ec528..16f52f3 100644
--- a/src/libtracker-common/tracker-keyfile-object.c
+++ b/src/libtracker-common/tracker-keyfile-object.c
@@ -227,7 +227,6 @@ tracker_keyfile_object_load_string_list (gpointer object,
GKeyFile *key_file,
const gchar *group,
const gchar *key,
- gboolean is_directory_list,
GSList **return_instead)
{
GSList *l;
@@ -240,27 +239,56 @@ tracker_keyfile_object_load_string_list (gpointer object,
g_return_if_fail (key != NULL);
value = g_key_file_get_string_list (key_file, group, key, NULL, NULL);
- if (is_directory_list) {
- l = directory_string_list_to_gslist ((const gchar **) value);
+ l = tracker_string_list_to_gslist (value, -1);
+ g_strfreev (value);
- if (l) {
- GSList *filtered;
+ if (G_LIKELY (!return_instead)) {
+ g_object_set (G_OBJECT (object), property, l, NULL);
- /* Should we make the basename (2nd argument) here
- * part of this function's API?
- */
- filtered = tracker_path_list_filter_duplicates (l, ".");
+ /* List is copied internally */
+ g_slist_foreach (l, (GFunc) g_free, NULL);
+ g_slist_free (l);
+ } else {
+ *return_instead = l;
+ }
+}
+
+void
+tracker_keyfile_object_load_directory_list (gpointer object,
+ const gchar *property,
+ GKeyFile *key_file,
+ const gchar *group,
+ const gchar *key,
+ gboolean is_recursive,
+ GSList **return_instead)
+{
+ GSList *l;
+ gchar **value;
- g_slist_foreach (l, (GFunc) g_free, NULL);
- g_slist_free (l);
+ g_return_if_fail (G_IS_OBJECT (object));
+ g_return_if_fail (property != NULL);
+ g_return_if_fail (key_file != NULL);
+ g_return_if_fail (group != NULL);
+ g_return_if_fail (key != NULL);
- l = filtered;
- }
- } else {
- l = tracker_string_list_to_gslist (value, -1);
- }
+ value = g_key_file_get_string_list (key_file, group, key, NULL, NULL);
+ l = directory_string_list_to_gslist ((const gchar **) value);
g_strfreev (value);
+ if (l) {
+ GSList *filtered;
+
+ /* Should we make the basename (2nd argument) here
+ * part of this function's API?
+ */
+ filtered = tracker_path_list_filter_duplicates (l, ".", is_recursive);
+
+ g_slist_foreach (l, (GFunc) g_free, NULL);
+ g_slist_free (l);
+
+ l = filtered;
+ }
+
if (G_LIKELY (!return_instead)) {
g_object_set (G_OBJECT (object), property, l, NULL);
@@ -357,3 +385,29 @@ tracker_keyfile_object_save_string_list (gpointer object,
g_strfreev (value);
}
+void
+tracker_keyfile_object_save_directory_list (gpointer object,
+ const gchar *property,
+ GKeyFile *key_file,
+ const gchar *group,
+ const gchar *key)
+{
+ GSList *list;
+ gchar **value;
+
+ g_return_if_fail (G_IS_OBJECT (object));
+ g_return_if_fail (property != NULL);
+ g_return_if_fail (key_file != NULL);
+ g_return_if_fail (group != NULL);
+ g_return_if_fail (key != NULL);
+
+ g_object_get (G_OBJECT (object), property, &list, NULL);
+
+ value = tracker_gslist_to_string_list (list);
+ g_key_file_set_string_list (key_file,
+ group,
+ key,
+ (const gchar * const *) value,
+ (gsize) g_slist_length (list));
+ g_strfreev (value);
+}
diff --git a/src/libtracker-common/tracker-keyfile-object.h b/src/libtracker-common/tracker-keyfile-object.h
index 6ad6b11..cc7be14 100644
--- a/src/libtracker-common/tracker-keyfile-object.h
+++ b/src/libtracker-common/tracker-keyfile-object.h
@@ -57,8 +57,15 @@ void tracker_keyfile_object_load_string_list (gpointer object,
GKeyFile *key_file,
const gchar *group,
const gchar *key,
- gboolean is_directory_list,
GSList **return_instead);
+void tracker_keyfile_object_load_directory_list (gpointer object,
+ const gchar *property,
+ GKeyFile *key_file,
+ const gchar *group,
+ const gchar *key,
+ gboolean is_recursive,
+ GSList **return_instead);
+
void tracker_keyfile_object_save_int (gpointer object,
const gchar *property,
GKeyFile *key_file,
@@ -79,6 +86,11 @@ void tracker_keyfile_object_save_string_list (gpointer object,
GKeyFile *key_file,
const gchar *group,
const gchar *key);
+void tracker_keyfile_object_save_directory_list (gpointer object,
+ const gchar *property,
+ GKeyFile *key_file,
+ const gchar *group,
+ const gchar *key);
G_END_DECLS
diff --git a/src/tracker-miner-fs/tracker-config.c b/src/tracker-miner-fs/tracker-config.c
index ec1868d..a1b9ce5 100644
--- a/src/tracker-miner-fs/tracker-config.c
+++ b/src/tracker-miner-fs/tracker-config.c
@@ -871,6 +871,7 @@ config_load (TrackerConfig *config,
case G_TYPE_POINTER: {
GSList *new_dirs, *old_dirs, *l;
gboolean check_for_duplicates = FALSE;
+ gboolean is_recursive = TRUE;
gboolean equal;
is_directory_list = TRUE;
@@ -882,18 +883,18 @@ config_load (TrackerConfig *config,
file->key_file,
conversions[i].group,
conversions[i].key,
- is_directory_list,
NULL);
continue;
}
- tracker_keyfile_object_load_string_list (G_OBJECT (file),
- conversions[i].property,
- file->key_file,
- conversions[i].group,
- conversions[i].key,
- is_directory_list,
- &new_dirs);
+ is_recursive = strcmp (conversions[i].property, "index-recursive-directories") == 0;
+ tracker_keyfile_object_load_directory_list (G_OBJECT (file),
+ conversions[i].property,
+ file->key_file,
+ conversions[i].group,
+ conversions[i].key,
+ is_recursive,
+ &new_dirs);
g_object_get (config, conversions[i].property, &old_dirs, NULL);
for (l = new_dirs; l; l = l->next) {
@@ -930,7 +931,7 @@ config_load (TrackerConfig *config,
if (check_for_duplicates) {
GSList *filtered;
- filtered = tracker_path_list_filter_duplicates (new_dirs, ".");
+ filtered = tracker_path_list_filter_duplicates (new_dirs, ".", is_recursive);
g_slist_foreach (new_dirs, (GFunc) g_free, NULL);
g_slist_free (new_dirs);
diff --git a/tests/libtracker-common/tracker-file-utils-test.c b/tests/libtracker-common/tracker-file-utils-test.c
index 771fe5a..0e25fc6 100644
--- a/tests/libtracker-common/tracker-file-utils-test.c
+++ b/tests/libtracker-common/tracker-file-utils-test.c
@@ -62,7 +62,7 @@ test_path_list_filter_duplicates (void)
input_as_list = array_as_list (input_roots);
- result = tracker_path_list_filter_duplicates (input_as_list, ".");
+ result = tracker_path_list_filter_duplicates (input_as_list, ".", TRUE);
g_assert_cmpint (3, ==, g_slist_length (result));
g_assert (string_in_list (result, "/home"));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]