evolution-data-server r9083 - in branches/camel-db-summary/camel: . providers/imap
- From: sragavan svn gnome org
- To: svn-commits-list gnome org
- Subject: evolution-data-server r9083 - in branches/camel-db-summary/camel: . providers/imap
- Date: Thu, 3 Jul 2008 05:19:40 +0000 (UTC)
Author: sragavan
Date: Thu Jul 3 05:19:40 2008
New Revision: 9083
URL: http://svn.gnome.org/viewvc/evolution-data-server?rev=9083&view=rev
Log:
Fix sync and improve imap sync.
Modified:
branches/camel-db-summary/camel/camel-db.c
branches/camel-db-summary/camel/camel-folder-search.c
branches/camel-db-summary/camel/camel-folder-summary.c
branches/camel-db-summary/camel/camel-folder-thread.c
branches/camel-db-summary/camel/camel-folder.c
branches/camel-db-summary/camel/providers/imap/camel-imap-folder.c
Modified: branches/camel-db-summary/camel/camel-db.c
==============================================================================
--- branches/camel-db-summary/camel/camel-db.c (original)
+++ branches/camel-db-summary/camel/camel-db.c Thu Jul 3 05:19:40 2008
@@ -521,7 +521,7 @@
sqlite3_free (table_creation_query);
safe_index = g_strdup_printf("INDEX-%s", folder_name);
- table_creation_query = sqlite3_mprintf ("CREATE INDEX IF NOT EXISTS %Q ON %Q (uid)", safe_index, folder_name);
+ table_creation_query = sqlite3_mprintf ("CREATE INDEX IF NOT EXISTS %Q ON %Q (uid, read, junk, deleted)", safe_index, folder_name);
ret = camel_db_add_to_transaction (cdb, table_creation_query, ex);
g_free (safe_index);
sqlite3_free (table_creation_query);
Modified: branches/camel-db-summary/camel/camel-folder-search.c
==============================================================================
--- branches/camel-db-summary/camel/camel-folder-search.c (original)
+++ branches/camel-db-summary/camel/camel-folder-search.c Thu Jul 3 05:19:40 2008
@@ -673,7 +673,7 @@
#if 0
v = search->summary_set?search->summary_set:search->summary;
- if (v->len - g_hash_table_size (search->folder->summary->loaded_infos) > 100 && !CAMEL_IS_VEE_FOLDER (search->folder)) {
+ if (v->len - g_hash_table_size (search->folder->summary->loaded_infos) > 50 && !CAMEL_IS_VEE_FOLDER (search->folder)) {
/* Load the DB contents. FIXME this 100 needs to be a better threshold to reload from DB. */
#warning "handle exception"
camel_folder_summary_reload_from_db (search->folder->summary, NULL);
Modified: branches/camel-db-summary/camel/camel-folder-summary.c
==============================================================================
--- branches/camel-db-summary/camel/camel-folder-summary.c (original)
+++ branches/camel-db-summary/camel/camel-folder-summary.c Thu Jul 3 05:19:40 2008
@@ -692,11 +692,11 @@
#warning "FIXME: I should have a better LRU algorithm "
static gboolean
-remove_item (char *key, CamelMessageInfo *info, CamelFolderSummary *s)
+remove_item (char *key, CamelMessageInfoBase *info, CamelFolderSummary *s)
{
d(printf("%d(%d)\t", info->refcount, info->dirty)); //camel_message_info_dump (info);
CAMEL_SUMMARY_LOCK(info->summary, ref_lock);
- if (info->refcount == 1 && !info->dirty) {
+ if (info->refcount == 1 && !info->dirty && !(info->flags & CAMEL_MESSAGE_FOLDER_FLAGGED)) {
CAMEL_SUMMARY_UNLOCK(info->summary, ref_lock);
/* Hackit so that hashtable isn;t corrupted. */
camel_pstring_free (info->uid);
Modified: branches/camel-db-summary/camel/camel-folder-thread.c
==============================================================================
--- branches/camel-db-summary/camel/camel-folder-thread.c (original)
+++ branches/camel-db-summary/camel/camel-folder-thread.c Thu Jul 3 05:19:40 2008
@@ -620,7 +620,7 @@
fsummary = camel_folder_get_summary(folder);
thread->summary = summary = g_ptr_array_new();
- if (fsummary->len > camel_folder_summary_cache_size (folder->summary))
+ if (fsummary->len - camel_folder_summary_cache_size (folder->summary) > 50)
camel_folder_summary_reload_from_db (folder->summary);
for (i = 0 ; i < fsummary->len ; i++) {
Modified: branches/camel-db-summary/camel/camel-folder.c
==============================================================================
--- branches/camel-db-summary/camel/camel-folder.c (original)
+++ branches/camel-db-summary/camel/camel-folder.c Thu Jul 3 05:19:40 2008
@@ -383,6 +383,7 @@
if (!CAMEL_IS_VEE_FOLDER (folder)) {
/* TODO: Locking? */
#warning "unread should be unread and not del/junk and take care of dirty infos also"
+ // camel_folder_summary_save_to_db (folder->summary, NULL);
camel_db_count_visible_unread_message_info (folder->cdb, folder->full_name, &unread, ex);
camel_db_count_junk_message_info (folder->cdb, folder->full_name, &junked, ex);
camel_db_count_deleted_message_info (folder->cdb, folder->full_name, &deleted, ex);
Modified: branches/camel-db-summary/camel/providers/imap/camel-imap-folder.c
==============================================================================
--- branches/camel-db-summary/camel/providers/imap/camel-imap-folder.c (original)
+++ branches/camel-db-summary/camel/providers/imap/camel-imap-folder.c Thu Jul 3 05:19:40 2008
@@ -907,6 +907,10 @@
* from the summary.
*/
removed = g_array_new (FALSE, FALSE, sizeof (int));
+
+ if (summary_len - camel_folder_summary_cache_size (folder->summary) > 50)
+ camel_folder_summary_reload_from_db (folder->summary);
+
for (i = 0; i < summary_len && new[i].uid; i++) {
gboolean changed = FALSE;
@@ -998,7 +1002,7 @@
* caller must free the infos, the array, and the set string.
*/
static GPtrArray *
-get_matching (CamelFolder *folder, guint32 flags, guint32 mask, CamelMessageInfo *master_info, char **set)
+get_matching (CamelFolder *folder, guint32 flags, guint32 mask, CamelMessageInfo *master_info, char **set, GPtrArray *summary)
{
GPtrArray *matches;
CamelImapMessageInfo *info;
@@ -1019,14 +1023,13 @@
matches = g_ptr_array_new ();
gset = g_string_new ("");
- max = camel_folder_summary_count (folder->summary);
+ max = summary->len;
range = -1;
for (i = 0; i < max && !UID_SET_FULL (gset->len, UID_SET_LIMIT); i++) {
- uid = camel_folder_summary_uid_from_index (folder->summary, i);
+ uid = summary->pdata[i];
if (uid) {
info = (CamelImapMessageInfo *) camel_folder_summary_uid (folder->summary, uid);
- g_free (uid);
} else
continue;
@@ -1081,6 +1084,10 @@
}
g_ptr_array_add (matches, info);
+ /* Remove the uid from the list, to optimize*/
+ camel_pstring_free(summary->pdata[i]);
+ summary->pdata[i] = NULL;
+
if (range != -1)
continue;
range = i;
@@ -1148,7 +1155,7 @@
CamelImapStore *store = CAMEL_IMAP_STORE (folder->parent_store);
CamelImapMessageInfo *info;
CamelException local_ex;
- GPtrArray *matches;
+ GPtrArray *matches, *summary;
char *set, *flaglist, *uid;
int i, j, max;
@@ -1164,14 +1171,16 @@
* messages like it, sync them as a group, mark them as
* updated, and continue.
*/
- max = camel_folder_summary_count (folder->summary);
+ summary = camel_folder_summary_get_changed (folder->summary); /* These should be in memory anyways*/
+ max = summary->len;
+
for (i = 0; i < max; i++) {
gboolean unset = FALSE;
CamelImapResponse *response = NULL;
- uid = camel_folder_summary_uid_from_index (folder->summary, i);
+ uid = summary->pdata[i];
- if (!uid)
+ if (!uid) /* Possibly it was sync by matching flags, which we NULLify */
continue;
if (!(info = (CamelImapMessageInfo *) camel_folder_summary_uid (folder->summary, uid))) {
@@ -1179,8 +1188,6 @@
continue;
}
- g_free (uid);
-
if (!(info->info.flags & CAMEL_MESSAGE_FOLDER_FLAGGED)) {
camel_message_info_free((CamelMessageInfo *)info);
continue;
@@ -1192,7 +1199,7 @@
they will be scooped up later by our parent loop (I
think?). -- Jeff */
matches = get_matching (folder, info->info.flags & (folder->permanent_flags | CAMEL_MESSAGE_FOLDER_FLAGGED),
- folder->permanent_flags | CAMEL_MESSAGE_FOLDER_FLAGGED, (CamelMessageInfo *)info, &set);
+ folder->permanent_flags | CAMEL_MESSAGE_FOLDER_FLAGGED, (CamelMessageInfo *)info, &set, summary);
camel_message_info_free(info);
if (matches == NULL)
continue;
@@ -1262,6 +1269,9 @@
/* Re-lock the connect_lock */
CAMEL_SERVICE_REC_LOCK (store, connect_lock);
}
+
+ g_ptr_array_foreach (summary, camel_pstring_free, NULL);
+ g_ptr_array_free (summary, TRUE);
/* Save the summary */
imap_sync_offline (folder, ex);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]