[tracker-miners/wip/carlosg/speed-track: 35/40] libtracker-miner: Pass GFileInfo via TrackerFileNotifier::created/updated
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker-miners/wip/carlosg/speed-track: 35/40] libtracker-miner: Pass GFileInfo via TrackerFileNotifier::created/updated
- Date: Sun, 18 Oct 2020 20:58:44 +0000 (UTC)
commit fa68f8ca3278cabbf1fd72d9c547fdd1cfea43c5
Author: Carlos Garnacho <carlosg gnome org>
Date: Sat Oct 17 17:32:53 2020 +0200
libtracker-miner: Pass GFileInfo via TrackerFileNotifier::created/updated
We are duplicating work, we have the TrackerCrawler inspecting every folder
and file, just to queue changed files, and then we go through these again
querying info individually.
This can be streamlined by pushing the GFileInfos from the TrackerCrawler
instead, so we don't need to query that info again. This commit just
does one step forward, letting this information available outside the
TrackerFileNotifier.
src/libtracker-miner/tracker-file-notifier.c | 32 ++++++++++++----------
src/libtracker-miner/tracker-file-notifier.h | 4 ++-
src/libtracker-miner/tracker-miner-fs.c | 8 +++---
.../libtracker-miner/tracker-file-notifier-test.c | 4 +--
4 files changed, 26 insertions(+), 22 deletions(-)
---
diff --git a/src/libtracker-miner/tracker-file-notifier.c b/src/libtracker-miner/tracker-file-notifier.c
index 3bc9626ef..0923a8f94 100644
--- a/src/libtracker-miner/tracker-file-notifier.c
+++ b/src/libtracker-miner/tracker-file-notifier.c
@@ -270,12 +270,10 @@ file_notifier_notify (GFile *file,
TrackerFileNotifierPrivate *priv;
GFile *current_root;
gboolean stop = FALSE;
- gboolean is_dir;
notifier = user_data;
priv = tracker_file_notifier_get_instance_private (notifier);
current_root = priv->current_index_root->current_dir;
- is_dir = file_data->is_dir_in_disk;
/* If we're crawling over a subdirectory of a root index, it's been
* already notified in the crawling op that made it processed, so avoid
@@ -289,14 +287,18 @@ file_notifier_notify (GFile *file,
if (file_data->state == FILE_STATE_DELETE) {
/* In store but not in disk, delete */
- g_signal_emit (notifier, signals[FILE_DELETED], 0, file, is_dir);
+ g_signal_emit (notifier, signals[FILE_DELETED], 0, file,
+ file_data->is_dir_in_store);
stop = TRUE;
} else if (file_data->state == FILE_STATE_CREATE) {
/* In disk but not in store, create */
- g_signal_emit (notifier, signals[FILE_CREATED], 0, file, is_dir);
+ g_signal_emit (notifier, signals[FILE_CREATED], 0, file,
+ tracker_crawler_get_file_info (priv->crawler, file));
} else if (file_data->state == FILE_STATE_UPDATE) {
/* File changed, update */
- g_signal_emit (notifier, signals[FILE_UPDATED], 0, file, FALSE, is_dir);
+ g_signal_emit (notifier, signals[FILE_UPDATED], 0, file,
+ tracker_crawler_get_file_info (priv->crawler, file),
+ FALSE);
}
return stop;
@@ -946,7 +948,7 @@ monitor_item_created_cb (TrackerMonitor *monitor,
}
}
- g_signal_emit (notifier, signals[FILE_CREATED], 0, file, is_directory);
+ g_signal_emit (notifier, signals[FILE_CREATED], 0, file, NULL);
}
static void
@@ -966,7 +968,7 @@ monitor_item_updated_cb (TrackerMonitor *monitor,
return;
}
- g_signal_emit (notifier, signals[FILE_UPDATED], 0, file, FALSE, is_directory);
+ g_signal_emit (notifier, signals[FILE_UPDATED], 0, file, NULL, FALSE);
}
static void
@@ -986,7 +988,7 @@ monitor_item_attribute_updated_cb (TrackerMonitor *monitor,
return;
}
- g_signal_emit (notifier, signals[FILE_UPDATED], 0, file, TRUE, is_directory);
+ g_signal_emit (notifier, signals[FILE_UPDATED], 0, file, NULL, TRUE);
}
static void
@@ -1142,7 +1144,7 @@ monitor_item_moved_cb (TrackerMonitor *monitor,
/* Source file was not stored, check dest file as new */
if (!is_directory || !dest_is_recursive) {
- g_signal_emit (notifier, signals[FILE_CREATED], 0, other_file,
is_directory);
+ g_signal_emit (notifier, signals[FILE_CREATED], 0, other_file, NULL);
} else if (is_directory) {
/* Crawl dest directory */
notifier_queue_root (notifier, other_file, flags, FALSE);
@@ -1187,7 +1189,7 @@ monitor_item_moved_cb (TrackerMonitor *monitor,
g_signal_emit (notifier, signals[FILE_MOVED], 0, file, other_file, is_directory);
if (extension_changed (file, other_file))
- g_signal_emit (notifier, signals[FILE_UPDATED], 0, other_file, FALSE,
is_directory);
+ g_signal_emit (notifier, signals[FILE_UPDATED], 0, other_file, NULL, FALSE);
}
g_object_unref (other_file);
@@ -1254,7 +1256,7 @@ indexing_tree_directory_removed (TrackerIndexingTree *indexing_tree,
} else if (tracker_indexing_tree_file_is_root (indexing_tree,
parent)) {
g_signal_emit (notifier, signals[FILE_CREATED],
- 0, directory, TRUE);
+ 0, directory, NULL);
}
g_object_unref (parent);
@@ -1325,8 +1327,8 @@ indexing_tree_child_updated (TrackerIndexingTree *indexing_tree,
notifier_queue_root (notifier, child, flags, FALSE);
} else if (tracker_indexing_tree_file_is_indexable (priv->indexing_tree,
child, child_info)) {
- g_signal_emit (notifier, signals[FILE_UPDATED], 0, child, FALSE,
- child_type == G_FILE_TYPE_DIRECTORY);
+ g_signal_emit (notifier, signals[FILE_UPDATED], 0,
+ child, child_info, FALSE);
}
}
@@ -1503,7 +1505,7 @@ tracker_file_notifier_class_init (TrackerFileNotifierClass *klass)
NULL, NULL,
NULL,
G_TYPE_NONE,
- 2, G_TYPE_FILE, G_TYPE_BOOLEAN);
+ 2, G_TYPE_FILE, G_TYPE_FILE_INFO);
signals[FILE_UPDATED] =
g_signal_new ("file-updated",
G_TYPE_FROM_CLASS (klass),
@@ -1513,7 +1515,7 @@ tracker_file_notifier_class_init (TrackerFileNotifierClass *klass)
NULL, NULL,
NULL,
G_TYPE_NONE,
- 3, G_TYPE_FILE, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN);
+ 3, G_TYPE_FILE, G_TYPE_FILE_INFO, G_TYPE_BOOLEAN);
signals[FILE_DELETED] =
g_signal_new ("file-deleted",
G_TYPE_FROM_CLASS (klass),
diff --git a/src/libtracker-miner/tracker-file-notifier.h b/src/libtracker-miner/tracker-file-notifier.h
index f5d8cf0bb..e563f3320 100644
--- a/src/libtracker-miner/tracker-file-notifier.h
+++ b/src/libtracker-miner/tracker-file-notifier.h
@@ -51,9 +51,11 @@ struct _TrackerFileNotifierClass {
GObjectClass parent_class;
void (* file_created) (TrackerFileNotifier *notifier,
- GFile *file);
+ GFile *file,
+ GFileInfo *info);
void (* file_updated) (TrackerFileNotifier *notifier,
GFile *file,
+ GFileInfo *info,
gboolean attributes_only);
void (* file_deleted) (TrackerFileNotifier *notifier,
GFile *file);
diff --git a/src/libtracker-miner/tracker-miner-fs.c b/src/libtracker-miner/tracker-miner-fs.c
index d368d5532..b3db85ebf 100644
--- a/src/libtracker-miner/tracker-miner-fs.c
+++ b/src/libtracker-miner/tracker-miner-fs.c
@@ -211,7 +211,7 @@ static void indexing_tree_directory_removed (TrackerIndexingTree
gpointer user_data);
static void file_notifier_file_created (TrackerFileNotifier *notifier,
GFile *file,
- gboolean is_dir,
+ GFileInfo *info,
gpointer user_data);
static void file_notifier_file_deleted (TrackerFileNotifier *notifier,
GFile *file,
@@ -219,8 +219,8 @@ static void file_notifier_file_deleted (TrackerFileNotifier
gpointer user_data);
static void file_notifier_file_updated (TrackerFileNotifier *notifier,
GFile *file,
+ GFileInfo *info,
gboolean attributes_only,
- gboolean is_dir,
gpointer user_data);
static void file_notifier_file_moved (TrackerFileNotifier *notifier,
GFile *source,
@@ -2011,7 +2011,7 @@ miner_fs_queue_event (TrackerMinerFS *fs,
static void
file_notifier_file_created (TrackerFileNotifier *notifier,
GFile *file,
- gboolean is_dir,
+ GFileInfo *info,
gpointer user_data)
{
TrackerMinerFS *fs = user_data;
@@ -2044,8 +2044,8 @@ file_notifier_file_deleted (TrackerFileNotifier *notifier,
static void
file_notifier_file_updated (TrackerFileNotifier *notifier,
GFile *file,
+ GFileInfo *info,
gboolean attributes_only,
- gboolean is_dir,
gpointer user_data)
{
TrackerMinerFS *fs = user_data;
diff --git a/tests/libtracker-miner/tracker-file-notifier-test.c
b/tests/libtracker-miner/tracker-file-notifier-test.c
index cc78e48b3..4451ef251 100644
--- a/tests/libtracker-miner/tracker-file-notifier-test.c
+++ b/tests/libtracker-miner/tracker-file-notifier-test.c
@@ -122,7 +122,7 @@ perform_file_operation (TestCommonContext *fixture,
static void
file_notifier_file_created_cb (TrackerFileNotifier *notifier,
GFile *file,
- gboolean is_dir,
+ GFileInfo *info,
gpointer user_data)
{
TestCommonContext *fixture = user_data;
@@ -143,8 +143,8 @@ file_notifier_file_created_cb (TrackerFileNotifier *notifier,
static void
file_notifier_file_updated_cb (TrackerFileNotifier *notifier,
GFile *file,
+ GFileInfo *info,
gboolean attributes_only,
- gboolean is_dir,
gpointer user_data)
{
TestCommonContext *fixture = user_data;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]