Commit c692dd05 authored by Carlos Garnacho's avatar Carlos Garnacho

libtracker-miner: Avoid info queries on TrackerCrawler directories

When asking to crawl a directory, we always perform a info query on
the directory itself. However, most often this is a directory that
is being recursively inspected, thus comes from the TrackerCrawler
itself.

This brings 2 benefits:
- Most often we avoid a redundant file info query
- We now only call check_directory() once per directory, fixing
  the accounting of directories in our debug output.
parent c22fdf1f
......@@ -373,6 +373,7 @@ directory_processing_data_add_child (DirectoryProcessingData *data,
static DirectoryRootInfo *
directory_root_info_new (GFile *file,
GFileInfo *file_info,
gchar *file_attributes,
TrackerDirectoryFlags flags)
{
......@@ -393,19 +394,7 @@ directory_root_info_new (GFile *file,
allow_stat = FALSE;
}
/* NOTE: GFileInfo is ABSOLUTELY required here, without it the
* TrackerFileNotifier will think that top level roots have
* been deleted because the GFileInfo GQuark does not exist.
*
* This is seen easily by mounting a removable device,
* indexing, then removing, then re-inserting that same
* device.
*
* The check is done later in the TrackerFileNotifier by
* looking up the qdata that we set in both conditions below.
*/
if (allow_stat && file_attributes) {
GFileInfo *file_info;
if (!file_info && allow_stat && file_attributes) {
GFileQueryInfoFlags file_flags;
file_flags = G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS;
......@@ -419,8 +408,7 @@ directory_root_info_new (GFile *file,
file_info_quark,
file_info,
(GDestroyNotify) g_object_unref);
} else {
GFileInfo *file_info;
} else if (!file_info) {
gchar *basename;
file_info = g_file_info_new ();
......@@ -905,6 +893,7 @@ tracker_crawler_get (TrackerCrawler *crawler,
TrackerCrawlerPrivate *priv;
DirectoryProcessingData *dir_data;
DirectoryRootInfo *info;
GFileInfo *file_info;
GTask *task;
g_return_if_fail (TRACKER_IS_CRAWLER (crawler));
......@@ -912,14 +901,16 @@ tracker_crawler_get (TrackerCrawler *crawler,
priv = tracker_crawler_get_instance_private (crawler);
info = directory_root_info_new (file, priv->file_attributes, flags);
file_info = tracker_crawler_get_file_info (crawler, file);
info = directory_root_info_new (file, file_info, priv->file_attributes, flags);
task = g_task_new (crawler, cancellable, callback, user_data);
g_task_set_task_data (task, info,
(GDestroyNotify) directory_root_info_free);
info->task = task;
info->crawler = crawler;
if (!check_directory (crawler, info, file)) {
if (!file_info && !check_directory (crawler, info, file)) {
g_task_return_boolean (task, FALSE);
g_object_unref (task);
return;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment