[tracker/progress] libtracker-data: Fix progress indication for rotated journals



commit ad771294c5ba5a9b7e712668be044e8ecacfdb7a
Author: Philip Van Hoof <philip codeminded be>
Date:   Tue Aug 3 16:03:56 2010 +0200

    libtracker-data: Fix progress indication for rotated journals

 src/libtracker-data/tracker-db-journal.c |   19 ++++++++++++++-----
 1 files changed, 14 insertions(+), 5 deletions(-)
---
diff --git a/src/libtracker-data/tracker-db-journal.c b/src/libtracker-data/tracker-db-journal.c
index a37734f..809224f 100644
--- a/src/libtracker-data/tracker-db-journal.c
+++ b/src/libtracker-data/tracker-db-journal.c
@@ -1621,9 +1621,12 @@ tracker_db_journal_reader_get_statement_id (gint *g_id,
 gdouble
 tracker_db_journal_reader_get_progress (void)
 {
-	gdouble chunk = 0, total = 0;
+	gdouble chunk = 0, total = 0, ret;
+	guint current_file;
 	static guint total_chunks = 0;
 
+	current_file = reader.current_file == 0 ? total_chunks -1 : reader.current_file -1;
+
 	if (!rotating_settings.rotate_progress_flag) {
 		gchar *test;
 		GFile *dest_dir;
@@ -1671,16 +1674,18 @@ tracker_db_journal_reader_get_progress (void)
 	}
 
 	if (total_chunks > 0) {
-		total = ((gdouble) ((gdouble) reader.current_file) / ((gdouble) total_chunks));
+		total = ((gdouble) ((gdouble) current_file) / ((gdouble) total_chunks));
 	}
 
 	if (reader.start != 0) {
 		/* When the last uncompressed part is being processed: */
 		gdouble percent = ((gdouble)(reader.end - reader.start));
-		chunk = (((gdouble)(reader.current - reader.start)) / percent);
+		ret = chunk = (((gdouble)(reader.current - reader.start)) / percent);
 	} else if (reader.underlying_stream) {
 		goffset size;
 
+		/* When a compressed part is being processed: */
+
 		if (!reader.underlying_stream_info) {
 			reader.underlying_stream_info =
 				g_file_input_stream_query_info (G_FILE_INPUT_STREAM (reader.underlying_stream),
@@ -1690,11 +1695,15 @@ tracker_db_journal_reader_get_progress (void)
 
 		if (reader.underlying_stream_info) {
 			size = g_file_info_get_size (reader.underlying_stream_info);
-			chunk = (gdouble) ((gdouble)g_seekable_tell (G_SEEKABLE (reader.underlying_stream))) / ((gdouble)size);
+			ret = chunk = (gdouble) ((gdouble)g_seekable_tell (G_SEEKABLE (reader.underlying_stream))) / ((gdouble)size);
 		}
 	}
 
-	return total + chunk;
+	if (total_chunks > 0) {
+		ret = total + (chunk / (gdouble) total_chunks);
+	}
+
+	return ret;
 }
 
 #if GLIB_CHECK_VERSION (2, 24, 2)



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