[tracker] tracker-extract: if requested max 0 bytes, don't even start extracting content



commit a6393e330c5d5604a426a94e91f1577ba0625b0d
Author: Aleksander Morgado <aleksander lanedo com>
Date:   Wed Sep 15 17:53:59 2010 +0200

    tracker-extract: if requested max 0 bytes, don't even start extracting content

 src/tracker-extract/tracker-extract-msoffice.c |   15 +++++++++++++++
 src/tracker-extract/tracker-extract-oasis.c    |    5 +++++
 src/tracker-extract/tracker-extract-text.c     |    5 +++++
 3 files changed, 25 insertions(+), 0 deletions(-)
---
diff --git a/src/tracker-extract/tracker-extract-msoffice.c b/src/tracker-extract/tracker-extract-msoffice.c
index 1bd2f41..2322699 100644
--- a/src/tracker-extract/tracker-extract-msoffice.c
+++ b/src/tracker-extract/tracker-extract-msoffice.c
@@ -647,6 +647,11 @@ extract_powerpoint_content (GsfInfile *infile,
 	GString *all_texts = NULL;
 	gsf_off_t last_document_container;
 
+	/* If no content requested, return */
+	if (max_bytes == 0) {
+		return NULL;
+	}
+
 	stream = gsf_infile_child_by_name (infile, "PowerPoint Document");
 
 	if (is_encrypted) {
@@ -801,6 +806,11 @@ extract_msword_content (GsfInfile *infile,
 	gint text_buffer_size = 0;
 	gsize n_bytes_remaining;
 
+	/* If no content requested, return */
+	if (n_bytes == 0) {
+		return NULL;
+	}
+
 	document_stream = gsf_infile_child_by_name (infile, "WordDocument");
 	if (document_stream == NULL) {
 		return NULL;
@@ -1427,6 +1437,11 @@ extract_excel_content (GsfInfile *infile,
 	guint saved_offset;
 	gsize n_bytes_remaining = n_bytes;
 
+	/* If no content requested, return */
+	if (n_bytes == 0) {
+		return NULL;
+	}
+
 	stream = gsf_infile_child_by_name (infile, "Workbook");
 
 	if (!stream) {
diff --git a/src/tracker-extract/tracker-extract-oasis.c b/src/tracker-extract/tracker-extract-oasis.c
index bcd5528..df29524 100644
--- a/src/tracker-extract/tracker-extract-oasis.c
+++ b/src/tracker-extract/tracker-extract-oasis.c
@@ -128,6 +128,11 @@ extract_oasis_content (const gchar          *uri,
 		NULL
 	};
 
+	/* If no content requested, return */
+	if (total_bytes == 0) {
+		return;
+	}
+
 	/* Create parse info */
 	info.current = ODT_TAG_TYPE_UNKNOWN;
 	info.file_type = file_type;
diff --git a/src/tracker-extract/tracker-extract-text.c b/src/tracker-extract/tracker-extract-text.c
index d28656a..4065117 100644
--- a/src/tracker-extract/tracker-extract-text.c
+++ b/src/tracker-extract/tracker-extract-text.c
@@ -50,6 +50,11 @@ get_file_content (const gchar *uri,
 	GError     *error = NULL;
 	gchar      *text;
 
+	/* If no content requested, return */
+	if (n_bytes == 0) {
+		return NULL;
+	}
+
 	/* Get filename from URI */
 	file = g_file_new_for_uri (uri);
 	stream = g_file_read (file, NULL, &error);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]