evolution-data-server r9377 - trunk/camel



Author: sragavan
Date: Mon Aug 18 10:35:35 2008
New Revision: 9377
URL: http://svn.gnome.org/viewvc/evolution-data-server?rev=9377&view=rev

Log:
2008-08-18  Srinivasa Ragavan  <sragavan novell com>

	* camel/camel-folder-summary.c: Add a way to save just the header. We
	can optimize it a lot.
	* camel/camel-folder-summary.h:


Modified:
   trunk/camel/ChangeLog
   trunk/camel/camel-folder-summary.c
   trunk/camel/camel-folder-summary.h

Modified: trunk/camel/camel-folder-summary.c
==============================================================================
--- trunk/camel/camel-folder-summary.c	(original)
+++ trunk/camel/camel-folder-summary.c	Mon Aug 18 10:35:35 2008
@@ -1318,22 +1318,23 @@
 	s->flags &= ~CAMEL_SUMMARY_DIRTY;
 
 	count = cfs_count_dirty(s);
-	printf("Saving %d/%d dirty records of %s\n", count, g_hash_table_size (s->loaded_infos), s->folder->full_name);
+	if (!count)
+		return 0;
 
-	if (count) {
-		camel_db_begin_transaction (cdb, ex);
+	printf("Saving %d/%d dirty records of %s\n", count, g_hash_table_size (s->loaded_infos), s->folder->full_name);
 
-		ret = save_message_infos_to_db (s, ex);
-		if (ret != 0) {
-			camel_db_abort_transaction (cdb, ex);
-			/* Failed, so lets reset the flag */
-			s->flags |= CAMEL_SUMMARY_DIRTY;
-			return -1;
-		}
+	camel_db_begin_transaction (cdb, ex);
 
-		camel_db_end_transaction (cdb, ex);
+	ret = save_message_infos_to_db (s, ex);
+	if (ret != 0) {
+		camel_db_abort_transaction (cdb, ex);
+		/* Failed, so lets reset the flag */
+		s->flags |= CAMEL_SUMMARY_DIRTY;
+		return -1;
 	}
 
+	camel_db_end_transaction (cdb, ex);
+
 	record = (((CamelFolderSummaryClass *)(CAMEL_OBJECT_GET_CLASS(s)))->summary_header_to_db (s, ex));
 	if (!record) {
 		s->flags |= CAMEL_SUMMARY_DIRTY;
@@ -1356,6 +1357,36 @@
 	return ret;
 }
 
+int
+camel_folder_summary_header_save_to_db (CamelFolderSummary *s, CamelException *ex)
+{
+	CamelDB *cdb = s->folder->cdb;
+	CamelFIRecord *record;
+	int ret;
+
+	d(printf ("\ncamel_folder_summary_header_save_to_db called \n"));
+
+	record = (((CamelFolderSummaryClass *)(CAMEL_OBJECT_GET_CLASS(s)))->summary_header_to_db (s, ex));
+	if (!record) {
+		return -1;
+	}
+	
+	camel_db_begin_transaction (cdb, ex);
+	ret = camel_db_write_folder_info_record (cdb, record, ex);
+	g_free (record->bdata);
+	g_free (record);
+
+	if (ret != 0) {
+		camel_db_abort_transaction (cdb, ex);
+		return -1;
+	}
+
+	camel_db_end_transaction (cdb, ex);
+
+	return ret;
+}
+
+
 /**
  * camel_folder_summary_save:
  * @summary: a #CamelFolderSummary object

Modified: trunk/camel/camel-folder-summary.h
==============================================================================
--- trunk/camel/camel-folder-summary.h	(original)
+++ trunk/camel/camel-folder-summary.h	Mon Aug 18 10:35:35 2008
@@ -340,6 +340,7 @@
 /* only load the header */
 int camel_folder_summary_header_load(CamelFolderSummary *summary);
 int camel_folder_summary_header_load_from_db (CamelFolderSummary *s, CamelStore *store, const char *folder_name, CamelException *ex);
+int camel_folder_summary_header_save_to_db (CamelFolderSummary *s, CamelException *ex);
 
 /* set the dirty bit on the summary */
 void camel_folder_summary_touch(CamelFolderSummary *summary);



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