[tracker/follow-symlinks: 3/7] libtracker-miner: Make sure we honour the _NO_STAT and _FOLLOW_SYMLINKS dir flags
- From: Martyn James Russell <mr src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/follow-symlinks: 3/7] libtracker-miner: Make sure we honour the _NO_STAT and _FOLLOW_SYMLINKS dir flags
- Date: Thu, 4 Sep 2014 16:31:35 +0000 (UTC)
commit 25d4935937caf516a7cc2d130a9d43b3a63d4a01
Author: Martyn Russell <martyn lanedo com>
Date: Thu Sep 4 17:26:54 2014 +0100
libtracker-miner: Make sure we honour the _NO_STAT and _FOLLOW_SYMLINKS dir flags
src/libtracker-miner/tracker-crawler.c | 9 +++++-
src/libtracker-miner/tracker-file-data-provider.c | 10 ++++++++
src/libtracker-miner/tracker-indexing-tree.c | 26 ++++++++++++++------
src/libtracker-miner/tracker-miner-fs.c | 1 +
4 files changed, 36 insertions(+), 10 deletions(-)
---
diff --git a/src/libtracker-miner/tracker-crawler.c b/src/libtracker-miner/tracker-crawler.c
index 94f7126..5e99550 100644
--- a/src/libtracker-miner/tracker-crawler.c
+++ b/src/libtracker-miner/tracker-crawler.c
@@ -473,6 +473,7 @@ directory_root_info_new (GFile *file,
{
DirectoryRootInfo *info;
DirectoryProcessingData *dir_info;
+ gboolean allow_stat = TRUE;
info = g_slice_new0 (DirectoryRootInfo);
@@ -484,13 +485,17 @@ directory_root_info_new (GFile *file,
info->flags = flags;
- if (file_attributes) {
+ if ((info->flags & TRACKER_DIRECTORY_FLAG_NO_STAT) != 0) {
+ allow_stat = FALSE;
+ }
+
+ if (allow_stat && file_attributes) {
GFileInfo *file_info;
GFileQueryInfoFlags file_flags;
file_flags = G_FILE_QUERY_INFO_NONE;
- if ((info->flags & TRACKER_DIRECTORY_FLAG_NO_STAT) != 0) {
+ if ((info->flags & TRACKER_DIRECTORY_FLAG_FOLLOW_SYMLINKS) == 0) {
file_flags |= G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS;
}
diff --git a/src/libtracker-miner/tracker-file-data-provider.c
b/src/libtracker-miner/tracker-file-data-provider.c
index de73267..7a29cbd 100644
--- a/src/libtracker-miner/tracker-file-data-provider.c
+++ b/src/libtracker-miner/tracker-file-data-provider.c
@@ -120,7 +120,17 @@ file_data_provider_begin (TrackerDataProvider *data_provider,
file_flags = G_FILE_QUERY_INFO_NONE;
+ /* We ignore the TRACKER_DIRECTORY_FLAG_NO_STAT here, it makes
+ * no sense to be at this point with that flag. So we warn
+ * about it...
+ */
if ((flags & TRACKER_DIRECTORY_FLAG_NO_STAT) != 0) {
+ g_warning ("Did not expect to have TRACKER_DIRECTORY_FLAG_NO_STAT "
+ "flag in %s(), continuing anyway...",
+ __FUNCTION__);
+ }
+
+ if ((flags & TRACKER_DIRECTORY_FLAG_FOLLOW_SYMLINKS) == 0) {
file_flags |= G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS;
}
diff --git a/src/libtracker-miner/tracker-indexing-tree.c b/src/libtracker-miner/tracker-indexing-tree.c
index 76591bf..2e02f48 100644
--- a/src/libtracker-miner/tracker-indexing-tree.c
+++ b/src/libtracker-miner/tracker-indexing-tree.c
@@ -40,7 +40,7 @@ typedef struct _FindNodeData FindNodeData;
struct _NodeData
{
GFile *file;
- guint flags : 7;
+ guint flags;
guint shallow : 1;
};
@@ -704,25 +704,35 @@ tracker_indexing_tree_file_is_indexable (TrackerIndexingTree *tree,
return FALSE;
}
- if (file_type == G_FILE_TYPE_UNKNOWN) {
+ /* Don't check file type if _NO_STAT is given in flags */
+ if (file_type == G_FILE_TYPE_UNKNOWN &&
+ (config_flags & TRACKER_DIRECTORY_FLAG_NO_STAT) != 0) {
GFileQueryInfoFlags file_flags;
file_flags = G_FILE_QUERY_INFO_NONE;
- if ((config_flags & TRACKER_DIRECTORY_FLAG_NO_STAT) != 0) {
+ if ((config_flags & TRACKER_DIRECTORY_FLAG_FOLLOW_SYMLINKS) == 0) {
file_flags |= G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS;
}
file_type = g_file_query_file_type (file, file_flags, NULL);
- }
- filter = (file_type == G_FILE_TYPE_DIRECTORY) ?
- TRACKER_FILTER_DIRECTORY : TRACKER_FILTER_FILE;
+ filter = (file_type == G_FILE_TYPE_DIRECTORY) ?
+ TRACKER_FILTER_DIRECTORY : TRACKER_FILTER_FILE;
- if (indexing_tree_file_is_filtered (tree, filter, file)) {
- return FALSE;
+ if (indexing_tree_file_is_filtered (tree, filter, file)) {
+ return FALSE;
+ }
+ } else if (file_type != G_FILE_TYPE_UNKNOWN) {
+ filter = (file_type == G_FILE_TYPE_DIRECTORY) ?
+ TRACKER_FILTER_DIRECTORY : TRACKER_FILTER_FILE;
+
+ if (indexing_tree_file_is_filtered (tree, filter, file)) {
+ return FALSE;
+ }
}
+ /* FIXME: Shouldn't we only do this for file_type == G_FILE_TYPE_DIRECTORY ? */
if (config_flags & TRACKER_DIRECTORY_FLAG_IGNORE) {
return FALSE;
}
diff --git a/src/libtracker-miner/tracker-miner-fs.c b/src/libtracker-miner/tracker-miner-fs.c
index ab4c2ce..df3fa0b 100644
--- a/src/libtracker-miner/tracker-miner-fs.c
+++ b/src/libtracker-miner/tracker-miner-fs.c
@@ -1862,6 +1862,7 @@ item_move (TrackerMinerFS *fs,
uri = g_file_get_uri (file);
source_uri = g_file_get_uri (source_file);
+ /* FIXME: Should check the _NO_STAT on TrackerDirectoryFlags first! */
file_info = g_file_query_info (file,
G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME ","
G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE ","
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]