Commit af005432 authored by Carlos Garnacho's avatar Carlos Garnacho

Merge branch 'wip/carlosg/trigger-filter-parent-on-monitor-events'

parents deb12ca3 044a75f6
......@@ -118,8 +118,6 @@ tracker_file_notifier_set_property (GObject *object,
switch (prop_id) {
case PROP_INDEXING_TREE:
priv->indexing_tree = g_value_dup_object (value);
tracker_monitor_set_indexing_tree (priv->monitor,
priv->indexing_tree);
break;
case PROP_DATA_PROVIDER:
priv->data_provider = g_value_dup_object (value);
......@@ -1113,20 +1111,16 @@ monitor_item_created_cb (TrackerMonitor *monitor,
TrackerFileNotifierPrivate *priv;
GFileType file_type;
GFile *canonical;
gboolean indexable;
priv = tracker_file_notifier_get_instance_private (notifier);
file_type = (is_directory) ? G_FILE_TYPE_DIRECTORY : G_FILE_TYPE_REGULAR;
if (!tracker_indexing_tree_file_is_indexable (priv->indexing_tree,
file, file_type)) {
/* File should not be indexed */
return ;
}
tracker_file_notifier_ensure_parents (notifier, file);
indexable = tracker_indexing_tree_file_is_indexable (priv->indexing_tree,
file, file_type);
if (!is_directory) {
gboolean indexable;
gboolean parent_indexable;
GList *children;
GFile *parent;
......@@ -1134,12 +1128,12 @@ monitor_item_created_cb (TrackerMonitor *monitor,
if (parent) {
children = g_list_prepend (NULL, file);
indexable = tracker_indexing_tree_parent_is_indexable (priv->indexing_tree,
parent,
children);
parent_indexable = tracker_indexing_tree_parent_is_indexable (priv->indexing_tree,
parent,
children);
g_list_free (children);
if (!indexable) {
if (!parent_indexable) {
/* New file triggered a directory content
* filter, remove parent directory altogether
*/
......@@ -1153,15 +1147,24 @@ monitor_item_created_cb (TrackerMonitor *monitor,
file_notifier_current_root_check_remove_directory (notifier, canonical);
tracker_file_system_forget_files (priv->file_system, canonical,
G_FILE_TYPE_UNKNOWN);
tracker_monitor_remove_recursively (priv->monitor, canonical);
g_object_unref (canonical);
return;
}
g_object_unref (parent);
}
if (!indexable)
return;
} else {
TrackerDirectoryFlags flags;
if (!indexable)
return;
/* If config for the directory is recursive,
* Crawl new entire directory and add monitors
*/
......@@ -1182,6 +1185,8 @@ monitor_item_created_cb (TrackerMonitor *monitor,
}
}
tracker_file_notifier_ensure_parents (notifier, file);
/* Fetch the interned copy */
canonical = tracker_file_system_get_file (priv->file_system,
file, file_type, NULL);
......@@ -1281,12 +1286,6 @@ monitor_item_deleted_cb (TrackerMonitor *monitor,
tracker_monitor_remove_recursively (priv->monitor, file);
}
if (!tracker_indexing_tree_file_is_indexable (priv->indexing_tree,
file, file_type)) {
/* File was not indexed */
return ;
}
if (!is_directory) {
TrackerDirectoryFlags flags;
gboolean indexable;
......@@ -1298,7 +1297,6 @@ monitor_item_deleted_cb (TrackerMonitor *monitor,
indexable = tracker_indexing_tree_parent_is_indexable (priv->indexing_tree,
parent, children);
g_object_unref (parent);
g_list_free (children);
/* note: This supposedly works, but in practice
......@@ -1310,15 +1308,23 @@ monitor_item_deleted_cb (TrackerMonitor *monitor,
/* New file was triggering a directory content
* filter, reindex parent directory altogether
*/
file = tracker_file_system_get_file (priv->file_system,
file,
G_FILE_TYPE_DIRECTORY,
NULL);
canonical = tracker_file_system_get_file (priv->file_system,
parent,
G_FILE_TYPE_DIRECTORY,
NULL);
tracker_indexing_tree_get_root (priv->indexing_tree,
file, &flags);
notifier_queue_root (notifier, file, flags, FALSE);
canonical, &flags);
notifier_queue_root (notifier, canonical, flags, FALSE);
return;
}
g_object_unref (parent);
}
if (!tracker_indexing_tree_file_is_indexable (priv->indexing_tree,
file, file_type)) {
/* File was not indexed */
return ;
}
/* Fetch the interned copy */
......
......@@ -314,7 +314,6 @@ tracker_monitor_finalize (GObject *object)
g_hash_table_unref (priv->cached_events);
g_hash_table_unref (priv->monitors);
g_clear_object (&priv->tree);
G_OBJECT_CLASS (tracker_monitor_parent_class)->finalize (object);
}
......@@ -670,17 +669,6 @@ monitor_event_cb (GFileMonitor *file_monitor,
if (!other_file) {
is_directory = check_is_directory (monitor, file);
/* Avoid non-indexable-files */
if (priv->tree &&
!tracker_indexing_tree_file_is_indexable (priv->tree,
file,
(is_directory ?
G_FILE_TYPE_DIRECTORY :
G_FILE_TYPE_REGULAR))) {
g_free (file_uri);
return;
}
other_file_uri = NULL;
g_debug ("Received monitor event:%d (%s) for %s:'%s'",
event_type,
......@@ -695,24 +683,6 @@ monitor_event_cb (GFileMonitor *file_monitor,
is_directory = check_is_directory (monitor, file);
}
/* Avoid doing anything of both
* file/other_file are non-indexable
*/
if (priv->tree &&
!tracker_indexing_tree_file_is_indexable (priv->tree,
file,
(is_directory ?
G_FILE_TYPE_DIRECTORY :
G_FILE_TYPE_REGULAR)) &&
!tracker_indexing_tree_file_is_indexable (priv->tree,
other_file,
(is_directory ?
G_FILE_TYPE_DIRECTORY :
G_FILE_TYPE_REGULAR))) {
g_free (file_uri);
return;
}
other_file_uri = g_file_get_uri (other_file);
g_debug ("Received monitor event:%d (%s) for files '%s'->'%s'",
event_type,
......@@ -842,39 +812,6 @@ tracker_monitor_get_enabled (TrackerMonitor *monitor)
return priv->enabled;
}
TrackerIndexingTree *
tracker_monitor_get_indexing_tree (TrackerMonitor *monitor)
{
TrackerMonitorPrivate *priv;
g_return_val_if_fail (TRACKER_IS_MONITOR (monitor), NULL);
priv = tracker_monitor_get_instance_private (monitor);
return priv->tree;
}
void
tracker_monitor_set_indexing_tree (TrackerMonitor *monitor,
TrackerIndexingTree *tree)
{
TrackerMonitorPrivate *priv;
g_return_if_fail (TRACKER_IS_MONITOR (monitor));
g_return_if_fail (!tree || TRACKER_IS_INDEXING_TREE (tree));
priv = tracker_monitor_get_instance_private (monitor);
if (priv->tree) {
g_object_unref (priv->tree);
priv->tree = NULL;
}
if (tree) {
priv->tree = g_object_ref (tree);
}
}
void
tracker_monitor_set_enabled (TrackerMonitor *monitor,
gboolean enabled)
......
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