[tracker/tracker-store] tracker-indexer: Keep mime_type around to improve performance
- From: Jürg Billeter <juergbi src gnome org>
- To: svn-commits-list gnome org
- Subject: [tracker/tracker-store] tracker-indexer: Keep mime_type around to improve performance
- Date: Thu, 25 Jun 2009 11:59:01 +0000 (UTC)
commit 9ee20db3696d6803ca3d2958e6a106e9c0d9ebd8
Author: Jürg Billeter <j bitron ch>
Date: Thu Jun 25 12:29:54 2009 +0200
tracker-indexer: Keep mime_type around to improve performance
src/tracker-indexer/modules/applications.c | 4 +-
src/tracker-indexer/modules/evolution-common.c | 4 ++-
src/tracker-indexer/modules/evolution-imap.c | 4 +-
src/tracker-indexer/modules/evolution-pop.c | 4 +-
src/tracker-indexer/modules/files.c | 6 ++--
src/tracker-indexer/modules/gaim-conversations.c | 4 +-
src/tracker-indexer/tracker-indexer.c | 34 +++++++------------
src/tracker-indexer/tracker-module-file.c | 4 +-
src/tracker-indexer/tracker-module-file.h | 4 +-
.../tracker-module-metadata-utils.c | 11 +++---
.../tracker-module-metadata-utils.h | 3 +-
11 files changed, 38 insertions(+), 44 deletions(-)
---
diff --git a/src/tracker-indexer/modules/applications.c b/src/tracker-indexer/modules/applications.c
index ae43707..b0c73ed 100644
--- a/src/tracker-indexer/modules/applications.c
+++ b/src/tracker-indexer/modules/applications.c
@@ -72,7 +72,7 @@ struct TrackerApplicationFileClass {
};
static GType tracker_application_file_get_type (void) G_GNUC_CONST;
-static TrackerSparqlBuilder * tracker_application_file_get_metadata (TrackerModuleFile *file);
+static TrackerSparqlBuilder * tracker_application_file_get_metadata (TrackerModuleFile *file, gchar **mime_type);
G_DEFINE_DYNAMIC_TYPE (TrackerApplicationFile, tracker_application_file, TRACKER_TYPE_MODULE_FILE);
@@ -121,7 +121,7 @@ insert_data_from_desktop_file (TrackerSparqlBuilder *sparql,
static TrackerSparqlBuilder *
-tracker_application_file_get_metadata (TrackerModuleFile *file)
+tracker_application_file_get_metadata (TrackerModuleFile *file, gchar **mime_type)
{
TrackerSparqlBuilder *sparql = NULL;
GKeyFile *key_file;
diff --git a/src/tracker-indexer/modules/evolution-common.c b/src/tracker-indexer/modules/evolution-common.c
index 78ba898..487f1ae 100644
--- a/src/tracker-indexer/modules/evolution-common.c
+++ b/src/tracker-indexer/modules/evolution-common.c
@@ -72,14 +72,16 @@ evolution_common_get_wrapper_metadata (GMimeDataWrapper *wrapper,
if (g_mime_data_wrapper_write_to_stream (wrapper, stream) != -1) {
GFile *file;
+ gchar *mime_type;
file = g_file_new_for_path (path);
g_mime_stream_flush (stream);
- tracker_module_metadata_utils_get_data (file, sparql);
+ tracker_module_metadata_utils_get_data (file, sparql, &mime_type);
g_object_unref (file);
g_unlink (path);
+ g_free (mime_type);
}
g_mime_stream_close (stream);
diff --git a/src/tracker-indexer/modules/evolution-imap.c b/src/tracker-indexer/modules/evolution-imap.c
index b6e0c58..0e75b97 100644
--- a/src/tracker-indexer/modules/evolution-imap.c
+++ b/src/tracker-indexer/modules/evolution-imap.c
@@ -73,7 +73,7 @@ static void tracker_evolution_imap_file_initialize (TrackerModule
static gchar * tracker_evolution_imap_file_get_uri (TrackerModuleFile *file);
static gchar * tracker_evolution_imap_file_get_text (TrackerModuleFile *file);
static TrackerSparqlBuilder *
- tracker_evolution_imap_file_get_metadata (TrackerModuleFile *file);
+ tracker_evolution_imap_file_get_metadata (TrackerModuleFile *file, gchar **mime_type);
static TrackerModuleFlags
tracker_evolution_imap_file_get_flags (TrackerModuleFile *file);
@@ -1085,7 +1085,7 @@ get_attachment_metadata (TrackerModuleFile *file,
}
static TrackerSparqlBuilder *
-tracker_evolution_imap_file_get_metadata (TrackerModuleFile *file)
+tracker_evolution_imap_file_get_metadata (TrackerModuleFile *file, gchar **mime_type)
{
TrackerEvolutionImapFile *self;
diff --git a/src/tracker-indexer/modules/evolution-pop.c b/src/tracker-indexer/modules/evolution-pop.c
index d13f94b..d9f9b5c 100644
--- a/src/tracker-indexer/modules/evolution-pop.c
+++ b/src/tracker-indexer/modules/evolution-pop.c
@@ -53,7 +53,7 @@ static void tracker_evolution_pop_file_initialize (TrackerModuleF
static gchar * tracker_evolution_pop_file_get_uri (TrackerModuleFile *file);
static gchar * tracker_evolution_pop_file_get_text (TrackerModuleFile *file);
static TrackerSparqlBuilder *
- tracker_evolution_pop_file_get_metadata (TrackerModuleFile *file);
+ tracker_evolution_pop_file_get_metadata (TrackerModuleFile *file, gchar **mime_type);
static TrackerModuleFlags
tracker_evolution_pop_file_get_flags (TrackerModuleFile *file);
@@ -419,7 +419,7 @@ get_attachment_metadata (TrackerModuleFile *file, GMimePart *part)
}
static TrackerSparqlBuilder *
-tracker_evolution_pop_file_get_metadata (TrackerModuleFile *file)
+tracker_evolution_pop_file_get_metadata (TrackerModuleFile *file, gchar **mime_type)
{
TrackerEvolutionPopFile *self;
TrackerSparqlBuilder *sparql;
diff --git a/src/tracker-indexer/modules/files.c b/src/tracker-indexer/modules/files.c
index 9d1a9a1..5cd3abf 100644
--- a/src/tracker-indexer/modules/files.c
+++ b/src/tracker-indexer/modules/files.c
@@ -58,7 +58,7 @@ struct TrackerRegularFileClass {
static GType tracker_regular_file_get_type (void) G_GNUC_CONST;
static gchar * tracker_regular_file_get_text (TrackerModuleFile *file);
-static TrackerSparqlBuilder * tracker_regular_file_get_metadata (TrackerModuleFile *file);
+static TrackerSparqlBuilder * tracker_regular_file_get_metadata (TrackerModuleFile *file, gchar **mime_type);
static void tracker_regular_file_cancel (TrackerModuleFile *file);
@@ -157,7 +157,7 @@ check_exclude_file (const gchar *path)
#endif /* ENABLE_FILE_EXCLUDE_CHECKING */
static TrackerSparqlBuilder *
-tracker_regular_file_get_metadata (TrackerModuleFile *file)
+tracker_regular_file_get_metadata (TrackerModuleFile *file, gchar **mime_type)
{
TrackerSparqlBuilder *sparql;
@@ -170,7 +170,7 @@ tracker_regular_file_get_metadata (TrackerModuleFile *file)
sparql = tracker_sparql_builder_new_update ();
tracker_sparql_builder_insert_open (sparql);
- if (!tracker_module_metadata_utils_get_data (tracker_module_file_get_file (file), sparql)) {
+ if (!tracker_module_metadata_utils_get_data (tracker_module_file_get_file (file), sparql, mime_type)) {
g_object_unref (sparql);
sparql = NULL;
}
diff --git a/src/tracker-indexer/modules/gaim-conversations.c b/src/tracker-indexer/modules/gaim-conversations.c
index 2f2d697..dce884b 100644
--- a/src/tracker-indexer/modules/gaim-conversations.c
+++ b/src/tracker-indexer/modules/gaim-conversations.c
@@ -62,7 +62,7 @@ static GType gaim_file_get_type (void) G_GNUC_CONST;
static gchar * gaim_file_get_text (TrackerModuleFile *file);
static TrackerSparqlBuilder *
- gaim_file_get_metadata (TrackerModuleFile *file);
+ gaim_file_get_metadata (TrackerModuleFile *file, gchar **mime_type);
G_DEFINE_DYNAMIC_TYPE (GaimFile, gaim_file, TRACKER_TYPE_MODULE_FILE)
@@ -93,7 +93,7 @@ gaim_file_get_text (TrackerModuleFile *file)
}
static TrackerSparqlBuilder *
-gaim_file_get_metadata (TrackerModuleFile *file)
+gaim_file_get_metadata (TrackerModuleFile *file, gchar **mime_type)
{
TrackerSparqlBuilder *sparql;
GFile *f;
diff --git a/src/tracker-indexer/tracker-indexer.c b/src/tracker-indexer/tracker-indexer.c
index ff98ad2..257741f 100644
--- a/src/tracker-indexer/tracker-indexer.c
+++ b/src/tracker-indexer/tracker-indexer.c
@@ -211,7 +211,8 @@ static void state_check (TrackerIndexer *indexer);
static void item_remove (TrackerIndexer *indexer,
PathInfo *info,
- const gchar *uri);
+ const gchar *uri,
+ const gchar *mime_type);
static void check_finished (TrackerIndexer *indexer,
gboolean interrupted);
@@ -1051,17 +1052,12 @@ query_property_value (TrackerIndexer *indexer,
static void
generate_item_thumbnail (TrackerIndexer *indexer,
- const gchar *uri)
+ const gchar *uri,
+ const gchar *mime_type)
{
- gchar *mime_type;
-
- mime_type = query_property_value (indexer, uri, NIE_MIME_TYPE);
-
if (mime_type && tracker_config_get_enable_thumbnails (indexer->private->config)) {
tracker_thumbnailer_queue_file (uri, mime_type);
}
-
- g_free (mime_type);
}
static void
@@ -1110,7 +1106,8 @@ static void
item_add_or_update (TrackerIndexer *indexer,
PathInfo *info,
const gchar *uri,
- TrackerSparqlBuilder *sparql)
+ TrackerSparqlBuilder *sparql,
+ const gchar *mime_type)
{
gchar *mount_point = NULL;
@@ -1168,7 +1165,7 @@ item_add_or_update (TrackerIndexer *indexer,
schedule_flush (indexer, FALSE);
}
- generate_item_thumbnail (indexer, uri);
+ generate_item_thumbnail (indexer, uri, mime_type);
#ifdef HAVE_HAL
if (tracker_storage_uri_is_on_removable_device (indexer->private->storage,
@@ -1322,10 +1319,10 @@ item_move (TrackerIndexer *indexer,
static void
item_remove (TrackerIndexer *indexer,
PathInfo *info,
- const gchar *uri)
+ const gchar *uri,
+ const gchar *mime_type)
{
gchar *mount_point = NULL;
- gchar *mime_type;
gchar *sparql;
g_debug ("Removing item: '%s' (no metadata was given by module)",
@@ -1342,13 +1339,8 @@ item_remove (TrackerIndexer *indexer,
return;
}
- /* Get mime type and remove thumbnail from thumbnailerd */
- mime_type = query_property_value (indexer, uri, NIE_MIME_TYPE);
-
if (mime_type) {
tracker_thumbnailer_remove (uri, mime_type);
-
- g_free (mime_type);
} else {
g_message ("Could not get mime type to remove thumbnail for:'%s'",
uri);
@@ -1384,9 +1376,9 @@ item_process (TrackerIndexer *indexer,
const gchar *uri)
{
TrackerSparqlBuilder *sparql;
- gchar *text;
+ gchar *text, *mime_type;
- sparql = tracker_module_file_get_metadata (info->module_file);
+ sparql = tracker_module_file_get_metadata (info->module_file, &mime_type);
if (tracker_module_file_is_cancelled (info->module_file)) {
if (sparql) {
@@ -1414,11 +1406,11 @@ item_process (TrackerIndexer *indexer,
g_free (text);
}
- item_add_or_update (indexer, info, uri, sparql);
+ item_add_or_update (indexer, info, uri, sparql, mime_type);
g_object_unref (sparql);
} else {
- item_remove (indexer, info, uri);
+ item_remove (indexer, info, uri, mime_type);
}
return TRUE;
diff --git a/src/tracker-indexer/tracker-module-file.c b/src/tracker-indexer/tracker-module-file.c
index ee074cf..6a97b18 100644
--- a/src/tracker-indexer/tracker-module-file.c
+++ b/src/tracker-indexer/tracker-module-file.c
@@ -249,12 +249,12 @@ tracker_module_file_get_text (TrackerModuleFile *file)
* the extracted metadata, or %NULL.
**/
TrackerSparqlBuilder *
-tracker_module_file_get_metadata (TrackerModuleFile *file)
+tracker_module_file_get_metadata (TrackerModuleFile *file, gchar **mime_type)
{
TrackerSparqlBuilder *sparql = NULL;
if (TRACKER_MODULE_FILE_GET_CLASS (file)->get_metadata != NULL) {
- sparql = TRACKER_MODULE_FILE_GET_CLASS (file)->get_metadata (file);
+ sparql = TRACKER_MODULE_FILE_GET_CLASS (file)->get_metadata (file, mime_type);
}
return sparql;
diff --git a/src/tracker-indexer/tracker-module-file.h b/src/tracker-indexer/tracker-module-file.h
index 4cdd0d3..56ce957 100644
--- a/src/tracker-indexer/tracker-module-file.h
+++ b/src/tracker-indexer/tracker-module-file.h
@@ -57,7 +57,7 @@ struct TrackerModuleFileClass {
void (* initialize) (TrackerModuleFile *file);
gchar * (* get_uri) (TrackerModuleFile *file);
gchar * (* get_text) (TrackerModuleFile *file);
- TrackerSparqlBuilder * (* get_metadata) (TrackerModuleFile *file);
+ TrackerSparqlBuilder * (* get_metadata) (TrackerModuleFile *file, gchar **mime_type);
TrackerModuleFlags (* get_flags) (TrackerModuleFile *file);
void (* cancel) (TrackerModuleFile *file);
};
@@ -69,7 +69,7 @@ GFile * tracker_module_file_get_file (TrackerModuleFile
G_CONST_RETURN gchar * tracker_module_file_get_service_type (TrackerModuleFile *file);
gchar * tracker_module_file_get_uri (TrackerModuleFile *file);
gchar * tracker_module_file_get_text (TrackerModuleFile *file);
-TrackerSparqlBuilder * tracker_module_file_get_metadata (TrackerModuleFile *file);
+TrackerSparqlBuilder * tracker_module_file_get_metadata (TrackerModuleFile *file, gchar **mime_type);
TrackerModuleFlags tracker_module_file_get_flags (TrackerModuleFile *file);
void tracker_module_file_cancel (TrackerModuleFile *file);
diff --git a/src/tracker-indexer/tracker-module-metadata-utils.c b/src/tracker-indexer/tracker-module-metadata-utils.c
index 0c60ec6..4e1d8fc 100644
--- a/src/tracker-indexer/tracker-module-metadata-utils.c
+++ b/src/tracker-indexer/tracker-module-metadata-utils.c
@@ -762,9 +762,9 @@ tracker_module_metadata_utils_get_text (GFile *file)
**/
gboolean
-tracker_module_metadata_utils_get_data (GFile *file, TrackerSparqlBuilder *sparql)
+tracker_module_metadata_utils_get_data (GFile *file, TrackerSparqlBuilder *sparql, gchar **mime_type)
{
- gchar *mime_type, *uri;
+ gchar *uri;
GFileInfo *file_info;
guint64 time_;
GFile *parent;
@@ -777,7 +777,7 @@ tracker_module_metadata_utils_get_data (GFile *file, TrackerSparqlBuilder *sparq
uri = g_file_get_uri (file);
- mime_type = tracker_file_get_mime_type (file);
+ *mime_type = g_strdup (g_file_info_get_content_type (file_info));
tracker_sparql_builder_subject_iri (sparql, uri);
tracker_sparql_builder_predicate (sparql, "a");
@@ -800,7 +800,7 @@ tracker_module_metadata_utils_get_data (GFile *file, TrackerSparqlBuilder *sparq
tracker_sparql_builder_object_string (sparql, g_file_info_get_display_name (file_info));
tracker_sparql_builder_predicate (sparql, "nie:mimeType");
- tracker_sparql_builder_object_string (sparql, mime_type);
+ tracker_sparql_builder_object_string (sparql, *mime_type);
tracker_sparql_builder_predicate (sparql, "nfo:fileSize");
tracker_sparql_builder_object_int64 (sparql, g_file_info_get_size (file_info));
@@ -812,9 +812,8 @@ tracker_module_metadata_utils_get_data (GFile *file, TrackerSparqlBuilder *sparq
tracker_sparql_builder_predicate (sparql, "nfo:fileLastAccessed");
tracker_sparql_builder_object_date (sparql, &time_);
- metadata_utils_get_embedded (file, mime_type, sparql);
+ metadata_utils_get_embedded (file, *mime_type, sparql);
- g_free (mime_type);
g_free (uri);
return TRUE;
diff --git a/src/tracker-indexer/tracker-module-metadata-utils.h b/src/tracker-indexer/tracker-module-metadata-utils.h
index b6d1e91..b4ce77f 100644
--- a/src/tracker-indexer/tracker-module-metadata-utils.h
+++ b/src/tracker-indexer/tracker-module-metadata-utils.h
@@ -34,7 +34,8 @@ G_BEGIN_DECLS
gboolean tracker_module_metadata_utils_get_data (GFile *file,
- TrackerSparqlBuilder *metadata);
+ TrackerSparqlBuilder *metadata,
+ gchar **mime_type);
gchar * tracker_module_metadata_utils_get_text (GFile *file);
void tracker_module_metadata_utils_cancel (GFile *file);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]