[tracker/tracker-store] tracker-extract: Remove redundant file stats
- From: Jürg Billeter <juergbi src gnome org>
- To: svn-commits-list gnome org
- Subject: [tracker/tracker-store] tracker-extract: Remove redundant file stats
- Date: Fri, 26 Jun 2009 11:37:58 +0000 (UTC)
commit 2316460056ecdb981ae18559e7c4c0aa9bdf882a
Author: Jürg Billeter <j bitron ch>
Date: Fri Jun 26 12:15:42 2009 +0200
tracker-extract: Remove redundant file stats
src/tracker-extract/tracker-extract.c | 113 +++++++-------------
.../tracker-module-metadata-utils.c | 5 +-
2 files changed, 43 insertions(+), 75 deletions(-)
---
diff --git a/src/tracker-extract/tracker-extract.c b/src/tracker-extract/tracker-extract.c
index 16ae43c..bc80fa9 100644
--- a/src/tracker-extract/tracker-extract.c
+++ b/src/tracker-extract/tracker-extract.c
@@ -192,17 +192,11 @@ static TrackerSparqlBuilder *
get_file_metadata (TrackerExtract *extract,
guint request_id,
const gchar *uri,
- const gchar *mime_)
+ const gchar *mime)
{
TrackerSparqlBuilder *statements;
- GFile *file;
- GFileInfo *info;
- GError *error = NULL;
- const gchar *attributes = NULL;
gchar *mime_used = NULL;
- goffset size = 0;
gchar *content_type = NULL;
- const gchar *mime = mime_;
/* Create hash table to send back */
statements = tracker_sparql_builder_new_update ();
@@ -211,91 +205,62 @@ get_file_metadata (TrackerExtract *extract,
#ifdef HAVE_STREAMANALYZER
tracker_topanalyzer_extract (uri, statements, &content_type);
-#endif
- if ((!mime || mime[0]=='\0') && content_type)
+ if ((!mime || mime[0]=='\0') && content_type) {
mime = content_type;
-
- file = g_file_new_for_uri (uri);
- if (!file) {
- g_warning ("Could not create GFile for uri:'%s'",
- uri);
- g_free (content_type);
- g_object_unref (statements);
- return NULL;
- }
-
- /* Blocks */
- if (!g_file_query_exists (file, NULL)) {
- g_warning ("File does not exist '%s'", uri);
- g_object_unref (file);
- g_free (content_type);
- g_object_unref (statements);
- return NULL;
}
+#endif
- /* Do we get size and mime? or just size? */
if (mime && *mime) {
- attributes =
- G_FILE_ATTRIBUTE_STANDARD_SIZE;
+ /* We know the mime */
+ mime_used = g_strdup (mime);
+ g_strstrip (mime_used);
} else {
- attributes =
- G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE ","
- G_FILE_ATTRIBUTE_STANDARD_SIZE;
- }
-
- info = g_file_query_info (file,
- attributes,
- G_FILE_QUERY_INFO_NONE,
- NULL,
- &error);
-
- if (error || !info) {
- tracker_dbus_request_comment (request_id,
- " Could not create GFileInfo for file size check, %s",
- error ? error->message : "no error given");
- g_error_free (error);
-
- if (info) {
- g_object_unref (info);
+ GFile *file;
+ GFileInfo *info;
+ GError *error = NULL;
+
+ file = g_file_new_for_uri (uri);
+ if (!file) {
+ g_warning ("Could not create GFile for uri:'%s'",
+ uri);
+ g_free (content_type);
+ g_object_unref (statements);
+ return NULL;
}
-
- g_object_unref (file);
- g_free (content_type);
- g_object_unref (statements);
- return NULL;
- }
-
- /* Check the size is actually non-zero */
- size = g_file_info_get_size (info);
- if (size < 1) {
- tracker_dbus_request_comment (request_id,
- " File size is 0 bytes, ignoring file");
+ info = g_file_query_info (file,
+ G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE,
+ G_FILE_QUERY_INFO_NONE,
+ NULL,
+ &error);
+
+ if (error || !info) {
+ tracker_dbus_request_comment (request_id,
+ " Could not create GFileInfo for file size check, %s",
+ error ? error->message : "no error given");
+ g_error_free (error);
- g_object_unref (info);
- g_object_unref (file);
+ if (info) {
+ g_object_unref (info);
+ }
- g_free (content_type);
- g_object_unref (statements);
- return NULL;
- }
+ g_object_unref (file);
+ g_free (content_type);
+ g_object_unref (statements);
+ return NULL;
+ }
- /* We know the mime */
- if (mime && *mime) {
- mime_used = g_strdup (mime);
- g_strstrip (mime_used);
- } else {
mime_used = g_strdup (g_file_info_get_content_type (info));
tracker_dbus_request_comment (request_id,
" Guessing mime type as '%s' for uri:'%s'",
mime_used,
uri);
- }
- g_object_unref (info);
- g_object_unref (file);
+ g_object_unref (info);
+ g_object_unref (file);
+ }
/* Now we have sanity checked everything, actually get the
* data we need from the extractors.
diff --git a/src/tracker-indexer/tracker-module-metadata-utils.c b/src/tracker-indexer/tracker-module-metadata-utils.c
index 4e1d8fc..90219cc 100644
--- a/src/tracker-indexer/tracker-module-metadata-utils.c
+++ b/src/tracker-indexer/tracker-module-metadata-utils.c
@@ -812,7 +812,10 @@ 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);
+ /* Check the size is actually non-zero */
+ if (g_file_info_get_size (file_info) > 0) {
+ metadata_utils_get_embedded (file, *mime_type, sparql);
+ }
g_free (uri);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]