[tracker/eligible: 1/2] tracker-miner-fs: Add tracker_miner_files_is_file_eligible
- From: JÃrg Billeter <juergbi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/eligible: 1/2] tracker-miner-fs: Add tracker_miner_files_is_file_eligible
- Date: Wed, 18 Apr 2012 08:48:25 +0000 (UTC)
commit dadb4f031ffc282de8fa9e8004301c62a8658a23
Author: JÃrg Billeter <j bitron ch>
Date: Wed Apr 18 10:41:38 2012 +0200
tracker-miner-fs: Add tracker_miner_files_is_file_eligible
Logic moved from tracker-miner-files-index.c, no change in behavior.
src/miners/fs/tracker-miner-files-index.c | 97 +++-------------------------
src/miners/fs/tracker-miner-files.c | 101 +++++++++++++++++++++++++++++
src/miners/fs/tracker-miner-files.h | 30 +++++----
3 files changed, 127 insertions(+), 101 deletions(-)
---
diff --git a/src/miners/fs/tracker-miner-files-index.c b/src/miners/fs/tracker-miner-files-index.c
index ed4c324..26ae704 100644
--- a/src/miners/fs/tracker-miner-files-index.c
+++ b/src/miners/fs/tracker-miner-files-index.c
@@ -312,9 +312,8 @@ handle_method_call_index_file (TrackerMinerFilesIndex *miner,
GVariant *parameters)
{
TrackerMinerFilesIndexPrivate *priv;
- TrackerConfig *config;
TrackerDBusRequest *request;
- GFile *file, *dir;
+ GFile *file;
GFileInfo *file_info;
gboolean is_dir;
gboolean do_checks = FALSE;
@@ -331,10 +330,6 @@ handle_method_call_index_file (TrackerMinerFilesIndex *miner,
file = g_file_new_for_uri (file_uri);
- g_object_get (priv->files_miner,
- "config", &config,
- NULL);
-
file_info = g_file_query_info (file,
G_FILE_ATTRIBUTE_STANDARD_TYPE,
G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
@@ -347,6 +342,8 @@ handle_method_call_index_file (TrackerMinerFilesIndex *miner,
g_error_free (internal_error);
+ g_object_unref (file);
+
return;
}
@@ -355,92 +352,19 @@ handle_method_call_index_file (TrackerMinerFilesIndex *miner,
#ifdef REQUIRE_LOCATION_IN_CONFIG
do_checks = TRUE;
-#endif /* REQUIRE_LOCATION_IN_CONFIG */
+ if (!tracker_miner_files_is_file_eligible (priv->files_miner, file)) {
+ internal_error = g_error_new_literal (1, 0, "File is not eligible to be indexed");
+ tracker_dbus_request_end (request, internal_error);
+ g_dbus_method_invocation_return_gerror (invocation, internal_error);
- if (is_dir) {
- dir = g_object_ref (file);
- } else {
-#ifdef REQUIRE_LOCATION_IN_CONFIG
- if (!tracker_miner_files_check_file (file,
- tracker_config_get_ignored_file_paths (config),
- tracker_config_get_ignored_file_patterns (config))) {
- internal_error = g_error_new_literal (1, 0, "File is not eligible to be indexed");
- tracker_dbus_request_end (request, internal_error);
- g_dbus_method_invocation_return_gerror (invocation, internal_error);
+ g_error_free (internal_error);
- g_error_free (internal_error);
+ g_object_unref (file);
- return;
- }
-#endif /* REQUIRE_LOCATION_IN_CONFIG */
-
- dir = g_file_get_parent (file);
+ return;
}
-
- if (dir) {
-#ifdef REQUIRE_LOCATION_IN_CONFIG
- gboolean found = FALSE;
- GSList *l;
-
- if (!tracker_miner_files_check_directory (dir,
- tracker_config_get_index_recursive_directories (config),
- tracker_config_get_index_single_directories (config),
- tracker_config_get_ignored_directory_paths (config),
- tracker_config_get_ignored_directory_patterns (config))) {
- internal_error = g_error_new_literal (1, 0, "File is not eligible to be indexed");
- tracker_dbus_request_end (request, internal_error);
- g_dbus_method_invocation_return_gerror (context, internal_error);
-
- g_error_free (internal_error);
-
- return;
- }
-
- l = tracker_config_get_index_recursive_directories (config);
-
- while (l && !found) {
- GFile *config_dir;
-
- config_dir = g_file_new_for_path ((gchar *) l->data);
-
- if (g_file_equal (dir, config_dir) ||
- g_file_has_prefix (dir, config_dir)) {
- found = TRUE;
- }
-
- g_object_unref (config_dir);
- l = l->next;
- }
-
- l = tracker_config_get_index_single_directories (config);
-
- while (l && !found) {
- GFile *config_dir;
-
- config_dir = g_file_new_for_path ((gchar *) l->data);
-
- if (g_file_equal (dir, config_dir)) {
- found = TRUE;
- }
-
- g_object_unref (config_dir);
- l = l->next;
- }
-
- if (!found) {
- internal_error = g_error_new_literal (1, 0, "File is not eligible to be indexed");
- tracker_dbus_request_end (request, internal_error);
- g_dbus_method_invocation_return_gerror (invocation, internal_error);
-
- g_error_free (internal_error);
-
- return;
- }
#endif /* REQUIRE_LOCATION_IN_CONFIG */
- g_object_unref (dir);
- }
-
if (is_dir) {
tracker_miner_fs_check_directory (TRACKER_MINER_FS (priv->files_miner), file, do_checks);
} else {
@@ -451,7 +375,6 @@ handle_method_call_index_file (TrackerMinerFilesIndex *miner,
g_dbus_method_invocation_return_value (invocation, NULL);
g_object_unref (file);
- g_object_unref (config);
}
static void
diff --git a/src/miners/fs/tracker-miner-files.c b/src/miners/fs/tracker-miner-files.c
index bcd1c42..f3b2e28 100644
--- a/src/miners/fs/tracker-miner-files.c
+++ b/src/miners/fs/tracker-miner-files.c
@@ -2993,3 +2993,104 @@ miner_files_add_removable_or_optical_directory (TrackerMinerFiles *mf,
flags);
g_object_unref (mount_point_file);
}
+
+gboolean
+tracker_miner_files_is_file_eligible (TrackerMinerFiles *miner,
+ GFile *file)
+{
+ TrackerConfig *config;
+ GFile *dir;
+ GFileInfo *file_info;
+ gboolean is_dir;
+
+ file_info = g_file_query_info (file,
+ G_FILE_ATTRIBUTE_STANDARD_TYPE,
+ G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
+ NULL, NULL);
+
+ if (!file_info) {
+ /* file does not exist */
+ return FALSE;
+ }
+
+ is_dir = (g_file_info_get_file_type (file_info) == G_FILE_TYPE_DIRECTORY);
+ g_object_unref (file_info);
+
+ g_object_get (miner,
+ "config", &config,
+ NULL);
+
+ if (is_dir) {
+ dir = g_object_ref (file);
+ } else {
+ if (!tracker_miner_files_check_file (file,
+ tracker_config_get_ignored_file_paths (config),
+ tracker_config_get_ignored_file_patterns (config))) {
+ /* file is not eligible to be indexed */
+ g_object_unref (config);
+ return FALSE;
+ }
+
+ dir = g_file_get_parent (file);
+ }
+
+ if (dir) {
+ gboolean found = FALSE;
+ GSList *l;
+
+ if (!tracker_miner_files_check_directory (dir,
+ tracker_config_get_index_recursive_directories (config),
+ tracker_config_get_index_single_directories (config),
+ tracker_config_get_ignored_directory_paths (config),
+ tracker_config_get_ignored_directory_patterns (config))) {
+ /* file is not eligible to be indexed */
+ g_object_unref (dir);
+ g_object_unref (config);
+ return FALSE;
+ }
+
+ l = tracker_config_get_index_recursive_directories (config);
+
+ while (l && !found) {
+ GFile *config_dir;
+
+ config_dir = g_file_new_for_path ((gchar *) l->data);
+
+ if (g_file_equal (dir, config_dir) ||
+ g_file_has_prefix (dir, config_dir)) {
+ found = TRUE;
+ }
+
+ g_object_unref (config_dir);
+ l = l->next;
+ }
+
+ l = tracker_config_get_index_single_directories (config);
+
+ while (l && !found) {
+ GFile *config_dir;
+
+ config_dir = g_file_new_for_path ((gchar *) l->data);
+
+ if (g_file_equal (dir, config_dir)) {
+ found = TRUE;
+ }
+
+ g_object_unref (config_dir);
+ l = l->next;
+ }
+
+ g_object_unref (dir);
+
+ if (!found) {
+ /* file is not eligible to be indexed */
+ g_object_unref (config);
+ return FALSE;
+ }
+ }
+
+ g_object_unref (config);
+
+ /* file is eligible to be indexed */
+ return TRUE;
+}
diff --git a/src/miners/fs/tracker-miner-files.h b/src/miners/fs/tracker-miner-files.h
index fc651fb..e7cf5cb 100644
--- a/src/miners/fs/tracker-miner-files.h
+++ b/src/miners/fs/tracker-miner-files.h
@@ -52,20 +52,22 @@ TrackerMiner *tracker_miner_files_new (TrackerConfig *conf
GError **error);
/* Convenience functions for --eligible tracker-miner-fs cmdline */
-gboolean tracker_miner_files_check_file (GFile *file,
- GSList *ignored_file_paths,
- GSList *ignored_file_patterns);
-gboolean tracker_miner_files_check_directory (GFile *file,
- GSList *index_recursive_directories,
- GSList *index_single_directories,
- GSList *ignored_directory_paths,
- GSList *ignored_directory_patterns);
-gboolean tracker_miner_files_check_directory_contents (GFile *parent,
- GList *children,
- GSList *ignored_content);
-gboolean tracker_miner_files_monitor_directory (GFile *file,
- gboolean enable_monitors,
- GSList *directories_to_check);
+gboolean tracker_miner_files_check_file (GFile *file,
+ GSList *ignored_file_paths,
+ GSList *ignored_file_patterns);
+gboolean tracker_miner_files_check_directory (GFile *file,
+ GSList *index_recursive_directories,
+ GSList *index_single_directories,
+ GSList *ignored_directory_paths,
+ GSList *ignored_directory_patterns);
+gboolean tracker_miner_files_check_directory_contents (GFile *parent,
+ GList *children,
+ GSList *ignored_content);
+gboolean tracker_miner_files_monitor_directory (GFile *file,
+ gboolean enable_monitors,
+ GSList *directories_to_check);
+gboolean tracker_miner_files_is_file_eligible (TrackerMinerFiles *miner,
+ GFile *file);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]