[evolution-patches] [GW-Mailer] Delete items in a bulk
- From: "P Sankar" <psankar novell com>
- To: <evolution-patches gnome org>
- Subject: [evolution-patches] [GW-Mailer] Delete items in a bulk
- Date: Wed, 19 Apr 2006 07:26:37 -0600
Hi,
Attached patch deletes items in a bulk instead of sending removeItem
calls one-by-one. Reduces the time taken. Please review.
Sankar
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution-data-server/camel/providers/groupwise/ChangeLog,v
retrieving revision 1.156
diff -u -p -r1.156 ChangeLog
--- ChangeLog 18 Apr 2006 15:15:30 -0000 1.156
+++ ChangeLog 19 Apr 2006 13:22:43 -0000
@@ -1,3 +1,8 @@
+2006-04-19 Sankar P <psankar novell com>
+
+ * camel-groupwise-folder.c :
+ Deletes items in bulk instead of one-by-one
+
2006-04-18 Sankar P <psankar novell com>
* camel-groupwise-folder.c: (groupwise_sync):
Index: camel-groupwise-folder.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/camel/providers/groupwise/camel-groupwise-folder.c,v
retrieving revision 1.130
diff -u -p -r1.130 camel-groupwise-folder.c
--- camel-groupwise-folder.c 18 Apr 2006 15:15:30 -0000 1.130
+++ camel-groupwise-folder.c 19 Apr 2006 13:22:43 -0000
@@ -61,6 +61,7 @@
#define JUNK_FOLDER "Junk Mail"
#define READ_CURSOR_MAX_IDS 500
#define MAX_ATTACHMENT_SIZE 1*1024*1024 /*In bytes*/
+#define GROUPWISE_BULK_DELETE_LIMIT 100
static CamelOfflineFolderClass *parent_class = NULL;
@@ -586,7 +587,9 @@ groupwise_sync (CamelFolder *folder, gbo
EGwConnectionStatus status;
EGwConnection *cnc;
int count, i;
-
+
+ GList *deleted_items = NULL, *deleted_head;
+
if (((CamelOfflineStore *) gw_store)->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL ||
((CamelService *)gw_store)->status == CAMEL_SERVICE_DISCONNECTED) {
groupwise_sync_summary (folder, ex);
@@ -606,7 +609,7 @@ groupwise_sync (CamelFolder *folder, gbo
count = camel_folder_summary_count (folder->summary);
CAMEL_GROUPWISE_FOLDER_LOCK (folder, cache_lock);
- for (i=0 ; i <count ; i++) {
+ for (i=0 ; i < count ; i++) {
guint32 flags = 0;
info = camel_folder_summary_index (folder->summary, i);
gw_info = (CamelGroupwiseMessageInfo *) info;
@@ -635,22 +638,57 @@ groupwise_sync (CamelFolder *folder, gbo
if (diff.changed & CAMEL_MESSAGE_SEEN)
read_items = g_list_append (read_items, (char *)uid);
if (diff.changed & CAMEL_MESSAGE_DELETED) {
- CAMEL_SERVICE_LOCK (gw_store, connect_lock);
- status = e_gw_connection_remove_item (cnc, container_id, uid);
- if (status == E_GW_CONNECTION_STATUS_OK) {
- CAMEL_GROUPWISE_FOLDER_LOCK (folder, cache_lock);
- camel_folder_summary_remove (folder->summary, info);
- camel_data_cache_remove(gw_folder->cache, "cache", uid, ex);
- CAMEL_GROUPWISE_FOLDER_UNLOCK (folder, cache_lock);
- i--; count--;
+ if (deleted_items)
+ deleted_items = g_list_prepend (deleted_items, (char *)camel_message_info_uid (info));
+ else {
+ g_list_free (deleted_head);
+ deleted_head = NULL;
+ deleted_head = deleted_items = g_list_prepend (deleted_items, (char *)camel_message_info_uid (info));
+ }
+
+ if (g_list_length (deleted_items) == GROUPWISE_BULK_DELETE_LIMIT ) {
+ CAMEL_SERVICE_LOCK (gw_store, connect_lock);
+ status = e_gw_connection_remove_items (cnc, container_id, deleted_items);
+ CAMEL_SERVICE_UNLOCK (gw_store, connect_lock);
+ if (status == E_GW_CONNECTION_STATUS_OK) {
+ char *uid;
+ while (deleted_items) {
+ uid = (char *)deleted_items->data;
+ CAMEL_GROUPWISE_FOLDER_LOCK (folder, cache_lock);
+ camel_folder_summary_remove_uid (folder->summary, uid);
+ camel_data_cache_remove(gw_folder->cache, "cache", uid, ex);
+ CAMEL_GROUPWISE_FOLDER_UNLOCK (folder, cache_lock);
+ deleted_items = g_list_next (deleted_items);
+ count -= GROUPWISE_BULK_DELETE_LIMIT;
+ i -= GROUPWISE_BULK_DELETE_LIMIT;
+ }
+ }
}
- CAMEL_SERVICE_UNLOCK (gw_store, connect_lock);
}
}
}
camel_message_info_free (info);
}
- CAMEL_GROUPWISE_FOLDER_UNLOCK (folder, cache_lock);
+
+ if (deleted_items) {
+ CAMEL_SERVICE_LOCK (gw_store, connect_lock);
+ status = e_gw_connection_remove_items (cnc, container_id, deleted_items);
+ CAMEL_SERVICE_UNLOCK (gw_store, connect_lock);
+ if (status == E_GW_CONNECTION_STATUS_OK) {
+ char *uid;
+ while (deleted_items) {
+ uid = (char *)deleted_items->data;
+ CAMEL_GROUPWISE_FOLDER_LOCK (folder, cache_lock);
+ camel_folder_summary_remove_uid (folder->summary, uid);
+ camel_data_cache_remove(gw_folder->cache, "cache", uid, ex);
+ CAMEL_GROUPWISE_FOLDER_UNLOCK (folder, cache_lock);
+ deleted_items = g_list_next (deleted_items);
+ count -= GROUPWISE_BULK_DELETE_LIMIT;
+ i -= GROUPWISE_BULK_DELETE_LIMIT;
+ }
+ }
+ g_list_free (deleted_head);
+ }
if (read_items && g_list_length (read_items)) {
CAMEL_SERVICE_LOCK (gw_store, connect_lock);
@@ -893,10 +931,6 @@ groupwise_refresh_folder(CamelFolder *fo
struct _folder_update_msg *msg;
gboolean check_all = FALSE;
- /* Sync-up the (un)read changes before getting updates,
- so that the getFolderList will reflect the most recent changes too */
- groupwise_sync (folder, FALSE, ex);
-
if (((CamelOfflineStore *) gw_store)->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL) {
g_warning ("In offline mode. Cannot refresh!!!\n");
return;
@@ -1960,8 +1994,10 @@ groupwise_expunge (CamelFolder *folder,
CamelFolderChangeInfo *changes;
int i, max;
gboolean delete = FALSE;
+ GList *deleted_items, *deleted_head;
+
-
+ deleted_items = NULL;
cnc = cnc_lookup (priv);
if (!cnc)
return;
@@ -1988,26 +2024,65 @@ groupwise_expunge (CamelFolder *folder,
info = camel_folder_summary_index (folder->summary, i);
ginfo = (CamelGroupwiseMessageInfo *) info;
if (ginfo && (ginfo->info.flags & CAMEL_MESSAGE_DELETED)) {
- const char *uid = camel_message_info_uid (info);
- CAMEL_SERVICE_LOCK (groupwise_store, connect_lock);
- status = e_gw_connection_remove_item (cnc, container_id, uid);
- if (status == E_GW_CONNECTION_STATUS_OK) {
+
+ if (deleted_items)
+ deleted_items = g_list_prepend (deleted_items, (char *)camel_message_info_uid (info));
+ else {
+ g_list_free (deleted_head);
+ deleted_head = NULL;
+ deleted_head = deleted_items = g_list_prepend (deleted_items, (char *)camel_message_info_uid (info));
+ }
+ if (g_list_length (deleted_items) == GROUPWISE_BULK_DELETE_LIMIT ) {
+ /* Read the FIXME below */
+ CAMEL_SERVICE_LOCK (groupwise_store, connect_lock);
+ status = e_gw_connection_remove_items (cnc, container_id, deleted_items);
+ CAMEL_SERVICE_UNLOCK (groupwise_store, connect_lock);
+ if (status == E_GW_CONNECTION_STATUS_OK) {
+ char *uid;
+ while (deleted_items) {
+ uid = (char *)deleted_items->data;
+ CAMEL_GROUPWISE_FOLDER_LOCK (folder, cache_lock);
+ camel_folder_change_info_remove_uid (changes, uid);
+ camel_folder_summary_remove_uid (folder->summary, uid);
+ camel_data_cache_remove(gw_folder->cache, "cache", uid, ex);
+ CAMEL_GROUPWISE_FOLDER_UNLOCK (folder, cache_lock);
+ deleted_items = g_list_next (deleted_items);
+ max -= GROUPWISE_BULK_DELETE_LIMIT;
+ i -= GROUPWISE_BULK_DELETE_LIMIT;
+ }
+ }
+ delete = TRUE;
+ }
+ }
+ camel_message_info_free (info);
+ }
+
+ if (deleted_items) {
+
+ /* FIXME: Make more mudular by putting these in a function and
+ call that in the above loop, here and in groupwise_sync */
+
+ CAMEL_SERVICE_LOCK (groupwise_store, connect_lock);
+ status = e_gw_connection_remove_items (cnc, container_id, deleted_items);
+ CAMEL_SERVICE_UNLOCK (groupwise_store, connect_lock);
+ if (status == E_GW_CONNECTION_STATUS_OK) {
+ char *uid;
+ while (deleted_items) {
+ uid = (char *)deleted_items->data;
CAMEL_GROUPWISE_FOLDER_LOCK (folder, cache_lock);
- camel_folder_change_info_remove_uid (changes, (char *) uid);
- camel_folder_summary_remove (folder->summary, info);
+ camel_folder_change_info_remove_uid (changes, uid);
+ camel_folder_summary_remove_uid (folder->summary, uid);
camel_data_cache_remove(gw_folder->cache, "cache", uid, ex);
CAMEL_GROUPWISE_FOLDER_UNLOCK (folder, cache_lock);
- delete = TRUE;
- i--; max--;
+ deleted_items = g_list_next (deleted_items);
}
- CAMEL_SERVICE_UNLOCK (groupwise_store, connect_lock);
}
- camel_message_info_free (info);
+ delete = TRUE;
+ g_list_free (deleted_head);
}
if (delete)
camel_object_trigger_event (CAMEL_OBJECT (folder), "folder_changed", changes);
-
g_free (container_id);
camel_folder_change_info_free (changes);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]