[tracker] tracker-miner-fs: Allow full paths in IgnoredDirectories & IgnoredFiles
- From: Martyn James Russell <mr src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [tracker] tracker-miner-fs: Allow full paths in IgnoredDirectories & IgnoredFiles
- Date: Tue, 29 Sep 2009 16:02:00 +0000 (UTC)
commit dcb1e4f598e36edd1c58ec05f8236869241555af
Author: Martyn Russell <martyn lanedo com>
Date: Tue Sep 29 16:59:40 2009 +0100
tracker-miner-fs: Allow full paths in IgnoredDirectories & IgnoredFiles
src/tracker-miner-fs/tracker-config.c | 110 +++++++++++++++++++++++-----
src/tracker-miner-fs/tracker-config.h | 12 +++-
src/tracker-miner-fs/tracker-miner-files.c | 33 ++++++--
3 files changed, 127 insertions(+), 28 deletions(-)
---
diff --git a/src/tracker-miner-fs/tracker-config.c b/src/tracker-miner-fs/tracker-config.c
index baba061..2bc408b 100644
--- a/src/tracker-miner-fs/tracker-config.c
+++ b/src/tracker-miner-fs/tracker-config.c
@@ -76,8 +76,12 @@ typedef struct {
GSList *ignored_directories;
GSList *ignored_directories_with_content;
GSList *ignored_files;
+
+ /* Convenience data */
GSList *ignored_directory_patterns;
+ GSList *ignored_directory_paths;
GSList *ignored_file_patterns;
+ GSList *ignored_file_paths;
} TrackerConfigPrivate;
typedef struct {
@@ -495,11 +499,21 @@ config_finalize (GObject *object)
NULL);
g_slist_free (priv->ignored_file_patterns);
+ g_slist_foreach (priv->ignored_file_paths,
+ (GFunc) g_free,
+ NULL);
+ g_slist_free (priv->ignored_file_paths);
+
g_slist_foreach (priv->ignored_directory_patterns,
(GFunc) g_pattern_spec_free,
NULL);
g_slist_free (priv->ignored_directory_patterns);
+ g_slist_foreach (priv->ignored_directory_paths,
+ (GFunc) g_free,
+ NULL);
+ g_slist_free (priv->ignored_directory_paths);
+
g_slist_foreach (priv->ignored_files, (GFunc) g_free, NULL);
g_slist_free (priv->ignored_files);
@@ -653,11 +667,11 @@ config_create_with_defaults (TrackerConfig *config,
}
static void
-config_set_ignored_file_patterns (TrackerConfig *config)
+config_set_ignored_file_conveniences (TrackerConfig *config)
{
TrackerConfigPrivate *priv;
- GPatternSpec *spec;
GSList *l;
+ GSList *paths = NULL;
GSList *patterns = NULL;
priv = TRACKER_CONFIG_GET_PRIVATE (config);
@@ -667,23 +681,39 @@ config_set_ignored_file_patterns (TrackerConfig *config)
NULL);
g_slist_free (priv->ignored_file_patterns);
+ g_slist_foreach (priv->ignored_file_paths,
+ (GFunc) g_free,
+ NULL);
+ g_slist_free (priv->ignored_file_paths);
+
for (l = priv->ignored_files; l; l = l->next) {
- /* g_message (" Adding file ignore pattern:'%s'", */
- /* (gchar *) l->data); */
- spec = g_pattern_spec_new (l->data);
- patterns = g_slist_prepend (patterns, spec);
+ const gchar *str = l->data;
+
+ if (!str) {
+ continue;
+ }
+
+ if (G_LIKELY (*str != G_DIR_SEPARATOR)) {
+ GPatternSpec *spec;
+
+ spec = g_pattern_spec_new (l->data);
+ patterns = g_slist_prepend (patterns, spec);
+ } else {
+ paths = g_slist_prepend (paths, g_strdup (l->data));
+ }
}
priv->ignored_file_patterns = g_slist_reverse (patterns);
+ priv->ignored_file_paths = g_slist_reverse (paths);
}
static void
-config_set_ignored_directory_patterns (TrackerConfig *config)
+config_set_ignored_directory_conveniences (TrackerConfig *config)
{
TrackerConfigPrivate *priv;
- GPatternSpec *spec;
GSList *l;
GSList *patterns = NULL;
+ GSList *paths = NULL;
priv = TRACKER_CONFIG_GET_PRIVATE (config);
@@ -692,14 +722,30 @@ config_set_ignored_directory_patterns (TrackerConfig *config)
NULL);
g_slist_free (priv->ignored_directory_patterns);
+ g_slist_foreach (priv->ignored_directory_paths,
+ (GFunc) g_free,
+ NULL);
+ g_slist_free (priv->ignored_directory_paths);
+
for (l = priv->ignored_directories; l; l = l->next) {
- /* g_message (" Adding directory ignore pattern:'%s'", */
- /* (gchar *) l->data); */
- spec = g_pattern_spec_new (l->data);
- patterns = g_slist_prepend (patterns, spec);
+ const gchar *str = l->data;
+
+ if (!str) {
+ continue;
+ }
+
+ if (G_LIKELY (*str != G_DIR_SEPARATOR)) {
+ GPatternSpec *spec;
+
+ spec = g_pattern_spec_new (l->data);
+ patterns = g_slist_prepend (patterns, spec);
+ } else {
+ paths = g_slist_prepend (paths, g_strdup (l->data));
+ }
}
priv->ignored_directory_patterns = g_slist_reverse (patterns);
+ priv->ignored_directory_paths = g_slist_reverse (paths);
}
static void
@@ -745,11 +791,7 @@ config_load (TrackerConfig *config)
GSList *dirs, *l;
gboolean check_for_duplicates = FALSE;
- if (strcmp (conversions[i].property, "ignored-files") == 0) {
- is_directory_list = FALSE;
- } else {
- is_directory_list = TRUE;
- }
+ is_directory_list = TRUE;
tracker_keyfile_object_load_string_list (G_OBJECT (file),
conversions[i].property,
@@ -813,8 +855,8 @@ config_load (TrackerConfig *config)
}
}
- config_set_ignored_file_patterns (config);
- config_set_ignored_directory_patterns (config);
+ config_set_ignored_file_conveniences (config);
+ config_set_ignored_directory_conveniences (config);
}
static gboolean
@@ -1407,6 +1449,9 @@ tracker_config_set_ignored_directories (TrackerConfig *config,
g_slist_foreach (l, (GFunc) g_free, NULL);
g_slist_free (l);
+ /* Re-set up the GPatternSpec list */
+ config_set_ignored_directory_conveniences (config);
+
g_object_notify (G_OBJECT (config), "ignored-directories");
}
@@ -1459,6 +1504,9 @@ tracker_config_set_ignored_files (TrackerConfig *config,
g_slist_foreach (l, (GFunc) g_free, NULL);
g_slist_free (l);
+ /* Re-set up the GPatternSpec list */
+ config_set_ignored_file_conveniences (config);
+
g_object_notify (G_OBJECT (config), "ignored-files");
}
@@ -1489,3 +1537,27 @@ tracker_config_get_ignored_file_patterns (TrackerConfig *config)
return priv->ignored_file_patterns;
}
+
+GSList *
+tracker_config_get_ignored_directory_paths (TrackerConfig *config)
+{
+ TrackerConfigPrivate *priv;
+
+ g_return_val_if_fail (TRACKER_IS_CONFIG (config), NULL);
+
+ priv = TRACKER_CONFIG_GET_PRIVATE (config);
+
+ return priv->ignored_directory_paths;
+}
+
+GSList *
+tracker_config_get_ignored_file_paths (TrackerConfig *config)
+{
+ TrackerConfigPrivate *priv;
+
+ g_return_val_if_fail (TRACKER_IS_CONFIG (config), NULL);
+
+ priv = TRACKER_CONFIG_GET_PRIVATE (config);
+
+ return priv->ignored_file_paths;
+}
diff --git a/src/tracker-miner-fs/tracker-config.h b/src/tracker-miner-fs/tracker-config.h
index 553d198..42f5f9f 100644
--- a/src/tracker-miner-fs/tracker-config.h
+++ b/src/tracker-miner-fs/tracker-config.h
@@ -105,10 +105,20 @@ void tracker_config_set_ignored_directories_with_content (TrackerConfig *
void tracker_config_set_ignored_files (TrackerConfig *config,
GSList *files);
-/* Convenience functions */
+/*
+ * Convenience functions:
+ */
+
+/* The _patterns() APIs return GPatternSpec pointers for basename
+ * pattern matching.
+ */
GSList * tracker_config_get_ignored_directory_patterns (TrackerConfig *config);
GSList * tracker_config_get_ignored_file_patterns (TrackerConfig *config);
+/* The _paths() APIs return string pointers for full paths matching */
+GSList * tracker_config_get_ignored_directory_paths (TrackerConfig *config);
+GSList * tracker_config_get_ignored_file_paths (TrackerConfig *config);
+
G_END_DECLS
#endif /* __TRACKER_MINER_FS_CONFIG_H__ */
diff --git a/src/tracker-miner-fs/tracker-miner-files.c b/src/tracker-miner-fs/tracker-miner-files.c
index e8c08b3..1b314ac 100644
--- a/src/tracker-miner-fs/tracker-miner-files.c
+++ b/src/tracker-miner-fs/tracker-miner-files.c
@@ -921,11 +921,13 @@ miner_files_check_file (TrackerMinerFS *fs,
GFileInfo *file_info;
GSList *l;
gchar *basename;
+ gchar *path;
gboolean should_process;
file_info = NULL;
should_process = FALSE;
basename = NULL;
+ path = NULL;
file_info = g_file_query_info (file,
G_FILE_ATTRIBUTE_STANDARD_IS_HIDDEN,
@@ -940,6 +942,14 @@ miner_files_check_file (TrackerMinerFS *fs,
/* Check module file ignore patterns */
mf = TRACKER_MINER_FILES (fs);
+ path = g_file_get_path (file);
+
+ for (l = tracker_config_get_ignored_file_paths (mf->private->config); l; l = l->next) {
+ if (strcmp (l->data, path) == 0) {
+ goto done;
+ }
+ }
+
basename = g_file_get_basename (file);
for (l = tracker_config_get_ignored_file_patterns (mf->private->config); l; l = l->next) {
@@ -951,12 +961,13 @@ miner_files_check_file (TrackerMinerFS *fs,
should_process = TRUE;
done:
+ g_free (basename);
+ g_free (path);
+
if (file_info) {
g_object_unref (file_info);
}
- g_free (basename);
-
return should_process;
}
@@ -968,6 +979,7 @@ miner_files_check_directory (TrackerMinerFS *fs,
GFileInfo *file_info;
GSList *l;
gchar *basename;
+ gchar *path;
gboolean should_process;
should_process = FALSE;
@@ -979,13 +991,13 @@ miner_files_check_directory (TrackerMinerFS *fs,
G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
NULL, NULL);
+ path = g_file_get_path (file);
+
if (file_info && g_file_info_get_is_hidden (file_info)) {
TrackerMinerFiles *mf;
GSList *allowed_directories;
- gchar *path;
mf = TRACKER_MINER_FILES (fs);
- path = g_file_get_path (file);
/* FIXME: We need to check if the file is actually a
* config specified location before blanket ignoring
@@ -1005,14 +1017,18 @@ miner_files_check_directory (TrackerMinerFS *fs,
should_process = TRUE;
}
- g_free (path);
-
/* Ignore hidden dirs */
goto done;
}
mf = TRACKER_MINER_FILES (fs);
+ for (l = tracker_config_get_ignored_directory_paths (mf->private->config); l; l = l->next) {
+ if (strcmp (l->data, path) == 0) {
+ goto done;
+ }
+ }
+
basename = g_file_get_basename (file);
for (l = tracker_config_get_ignored_file_patterns (mf->private->config); l; l = l->next) {
@@ -1025,12 +1041,13 @@ miner_files_check_directory (TrackerMinerFS *fs,
should_process = TRUE;
done:
+ g_free (basename);
+ g_free (path);
+
if (file_info) {
g_object_unref (file_info);
}
- g_free (basename);
-
return should_process;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]